Uploaded image for project: 'Isis'
  1. Isis
  2. ISIS-321

gracefully handle any constraint violation thrown by the DataNucleus persistence mechanism (to be handled by JDO ObjectStore & Wicket)

    Details

      Description

      eg: if add the @Unique annotation to a field, should get back a user-friendly message in the action panel (or equally, in the edit object entity page).

      Instead, at the moment going straight to a 500 stack trace (see below as to what we get).

      What we want:

      • need to catch a runtimeexception in the actionPage and the EntityPage in the wicket viewer, and to render in a feedback panel

      Ideas on how to accomplish this:

      • in this particular case, we'd've expected there to be a validate on the action, which (barring a race condition) would have detected the error
      • nevertheless, occasionally race conditions will occur, and/or the domain programmer just forgot to implement the validation
      • in these cases, we'd still like a user friendly message, but perhaps should also log so that the programmer knows about it and can decide if it was a real problem or not
      • thus, could provide some sort of "ErrorHandlingService" that would take an exception and try to generate a sensible message to display; would be a knowledge base of lookup codes, regexs etc. If none available, then would just use the ex.getMessage()
      • in all cases, the exception would be logged and the progammer/administrator would use a tool such as Nagios/Zabbix etc to do the actual monitoring of the health of the app

      Here's an example of the kind of stack trace that such a service would need to handle:

      javax.jdo.JDODataStoreException: Insert of object "org.estatio.dom.asset.Property@45d0e784" using statement "INSERT INTO PROPERTY (DISPOSALDATE,OPENINGDATE,AREA,"NAME",ACQUIREDATE,"TYPE",REFERENCE) VALUES (?,?,?,?,?,?,?)" failed : integrity constraint violation: unique constraint or index violation; REFERENCE_IDX table: PROPERTY
      at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:421)
      at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:736)
      at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:756)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucleusCreateObjectCommand.execute(DataNucleusCreateObjectCommand.java:53)
      at org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.executeCommands(DataNucleusObjectStore.java:346)
      at org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.execute(DataNucleusObjectStore.java:340)
      at org.apache.isis.core.runtime.system.transaction.IsisTransaction.doFlush(IsisTransaction.java:350)
      at org.apache.isis.core.runtime.system.transaction.IsisTransaction.flush(IsisTransaction.java:314)
      at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel$ResultType$1.addResultsAccordingToSingleResultsMode(ActionPanel.java:194)
      at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel$ResultType$1.addResults(ActionPanel.java:164)
      at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionAndProcessResults(ActionPanel.java:133)
      at org.apache.isis.viewer.wicket.ui.actions.params.ActionParametersFormPanel$ActionParameterForm$1.onSubmit(ActionParametersFormPanel.java:121)
      at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1235)
      at org.apache.wicket.markup.html.form.Form.process(Form.java:921)
      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:767)
      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:700)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
      at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
      at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
      at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
      at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:830)
      at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
      at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:253)
      at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:210)
      at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:281)
      at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)
      at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:245)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
      at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
      at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
      at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
      at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
      at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
      at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
      at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:326)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
      NestedThrowablesStackTrace:
      java.sql.SQLIntegrityConstraintViolationException: integrity constraint violation: unique constraint or index violation; REFERENCE_IDX table: PROPERTY
      at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
      at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
      at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
      at org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate(Unknown Source)
      at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
      at org.datanucleus.store.rdbms.SQLController.executeStatementUpdate(SQLController.java:419)
      at org.datanucleus.store.rdbms.request.InsertRequest.execute(InsertRequest.java:411)
      at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertTable(RDBMSPersistenceHandler.java:166)
      at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObject(RDBMSPersistenceHandler.java:142)
      at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2381)
      at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:2357)
      at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1896)
      at org.datanucleus.ObjectManagerImpl.persistObjectWork(ObjectManagerImpl.java:1745)
      at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1593)
      at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:731)
      at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:756)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucleusCreateObjectCommand.execute(DataNucleusCreateObjectCommand.java:53)
      at org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.executeCommands(DataNucleusObjectStore.java:346)
      at org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.execute(DataNucleusObjectStore.java:340)
      at org.apache.isis.core.runtime.system.transaction.IsisTransaction.doFlush(IsisTransaction.java:350)
      at org.apache.isis.core.runtime.system.transaction.IsisTransaction.flush(IsisTransaction.java:314)
      at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel$ResultType$1.addResultsAccordingToSingleResultsMode(ActionPanel.java:194)
      at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel$ResultType$1.addResults(ActionPanel.java:164)
      at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionAndProcessResults(ActionPanel.java:133)
      at org.apache.isis.viewer.wicket.ui.actions.params.ActionParametersFormPanel$ActionParameterForm$1.onSubmit(ActionParametersFormPanel.java:121)
      at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1235)
      at org.apache.wicket.markup.html.form.Form.process(Form.java:921)
      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:767)
      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:700)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
      at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
      at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
      at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
      at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:830)
      at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
      at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:253)
      at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:210)
      at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:281)
      at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)
      at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:245)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
      at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
      at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
      at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
      at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
      at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
      at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
      at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:326)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
      Caused by: org.hsqldb.HsqlException: integrity constraint violation: unique constraint or index violation; REFERENCE_IDX table: PROPERTY
      at org.hsqldb.error.Error.error(Unknown Source)
      at org.hsqldb.Constraint.getException(Unknown Source)
      at org.hsqldb.index.IndexAVLMemory.insert(Unknown Source)
      at org.hsqldb.persist.RowStoreAVL.indexRow(Unknown Source)
      at org.hsqldb.TransactionManager2PL.addInsertAction(Unknown Source)
      at org.hsqldb.Session.addInsertAction(Unknown Source)
      at org.hsqldb.Table.insertSingleRow(Unknown Source)
      at org.hsqldb.StatementDML.insertSingleRow(Unknown Source)
      at org.hsqldb.StatementInsert.getResult(Unknown Source)
      at org.hsqldb.StatementDMQL.execute(Unknown Source)
      at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
      at org.hsqldb.Session.execute(Unknown Source)
      ... 65 more

      and also

      org.hsqldb.HsqlException: integrity constraint violation: unique constraint or index violation; REFERENCE_IDX table: PROPERTY
      at org.hsqldb.error.Error.error(Unknown Source)
      at org.hsqldb.Constraint.getException(Unknown Source)
      at org.hsqldb.index.IndexAVLMemory.insert(Unknown Source)
      at org.hsqldb.persist.RowStoreAVL.indexRow(Unknown Source)
      at org.hsqldb.TransactionManager2PL.addInsertAction(Unknown Source)
      at org.hsqldb.Session.addInsertAction(Unknown Source)
      at org.hsqldb.Table.insertSingleRow(Unknown Source)
      at org.hsqldb.StatementDML.insertSingleRow(Unknown Source)
      at org.hsqldb.StatementInsert.getResult(Unknown Source)
      at org.hsqldb.StatementDMQL.execute(Unknown Source)
      at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
      at org.hsqldb.Session.execute(Unknown Source)
      at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
      at org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate(Unknown Source)
      at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
      at org.datanucleus.store.rdbms.SQLController.executeStatementUpdate(SQLController.java:419)
      at org.datanucleus.store.rdbms.request.InsertRequest.execute(InsertRequest.java:411)
      at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertTable(RDBMSPersistenceHandler.java:166)
      at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObject(RDBMSPersistenceHandler.java:142)
      at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2381)
      at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:2357)
      at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1896)
      at org.datanucleus.ObjectManagerImpl.persistObjectWork(ObjectManagerImpl.java:1745)
      at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1593)
      at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:731)
      at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:756)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucleusCreateObjectCommand.execute(DataNucleusCreateObjectCommand.java:53)
      at org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.executeCommands(DataNucleusObjectStore.java:346)
      at org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.execute(DataNucleusObjectStore.java:340)
      at org.apache.isis.core.runtime.system.transaction.IsisTransaction.doFlush(IsisTransaction.java:350)
      at org.apache.isis.core.runtime.system.transaction.IsisTransaction.flush(IsisTransaction.java:314)
      at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel$ResultType$1.addResultsAccordingToSingleResultsMode(ActionPanel.java:194)
      at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel$ResultType$1.addResults(ActionPanel.java:164)
      at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionAndProcessResults(ActionPanel.java:133)
      at org.apache.isis.viewer.wicket.ui.actions.params.ActionParametersFormPanel$ActionParameterForm$1.onSubmit(ActionParametersFormPanel.java:121)
      at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1235)
      at org.apache.wicket.markup.html.form.Form.process(Form.java:921)
      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:767)
      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:700)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
      at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
      at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
      at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
      at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:830)
      at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
      at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:253)
      at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:210)
      at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:281)
      at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)
      at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:245)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
      at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
      at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
      at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
      at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
      at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
      at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
      at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                danhaywood Dan Haywood
                Reporter:
                jcvanderwal Jeroen van der Wal
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: