7 Replies Latest reply on Mar 27, 2006 6:57 AM by send2shriram

    Exception Handling  in JBPM

    send2shriram

      Hi,

      We tried to load a taskInstance whose id deosn;t exist in JBPM_TASKINSTANCE table, using the API;

      jbpmContext.loadTaskInstance(taskID);

      But JBPM does;nt give me an error saying that taskinstance doesn;t exists.
      Instead it returned me a taskInstance whose taskID is 0, and all other values are null.

      When i tried to use any getter method on the retreived taskInstance , it
      throws me

      org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.jbpm.taskmgmt.exe.TaskInstance#15912]


      at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
      at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:65)
      at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
      at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
      at org.jbpm.taskmgmt.exe.TaskInstance$$EnhancerByCGLIB$$6985c70e.setActorId()
      at org.iata.idfs.t2005.agentlink.workflow.impl.jbpm.task.JBPMTaskHelper.saveTaskDataVariables(JBPMTaskHelper.java:382)
      at org.iata.idfs.t2005.agentlink.workflow.impl.jbpm.task.JBPMTaskHelper.updateTask(JBPMTaskHelper.java:173)
      at org.iata.idfs.t2005.agentlink.workflow.impl.jbpm.JBPMWorkFlowImpl.updateTask(JBPMWorkFlowImpl.java:186)
      at org.iata.idfs.t2005.agentlink.workflow.impl.WorkflowProcessUtil.invokeTaskOperation(WorkflowProcessUtil.java:151)
      at org.iata.idfs.t2005.agentlink.workflow.impl.WorkflowProcessUtil.invokeWorkflow(WorkflowProcessUtil.java:66)
      at org.iata.idfs.t2005.agentlink.service.workflowservice.WorkflowService.processRequestInternal(WorkflowService.java:120)
      at org.iata.idfs.t2005.platform.service.AbstractServiceImpl.processRequest(AbstractServiceImpl.java:140)
      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.jboss.invocation.Invocation.performCall(Invocation.java:345)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:130)
      at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:873)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:413)
      at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:88)
      at $Proxy112.processRequest(Unknown Source)
      at org.iata.idfs.t2005.platform.ServiceCompartmentImpl.processRequest(ServiceCompartmentImpl.java:110)
      at org.iata.idfs.t2005.platform.BusImpl.invokeService(BusImpl.java:128)
      at org.iata.idfs.t2005.platform.BrokerImpl.processRequest(BrokerImpl.java:114)
      at org.iata.idfs.t2005.platform.RemoteBrokerBean.processRequest(RemoteBrokerBean.java:75)
      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.jboss.invocation.Invocation.performCall(Invocation.java:345)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:130)
      at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:389)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:873)
      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.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
      at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:179)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:165)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
      at $Proxy207.processRequest(Unknown Source)
      at org.iata.idfs.t2005.platform.BrokerProxy.processRequest(BrokerProxy.java:107)
      at com.iata.idfs.t2005.platform.web.serviceclient.ServiceClientServlet.doPost(ServiceClientServlet.java:145)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Unknown Source)



      How to handle this kind of scenario ?

      Please help me in solving this.


      Thanks in Adv
      Shriram

        • 1. Re: Exception Handling  in JBPM
          send2shriram

          Can anybody help on this ?

          This is a serious problem !!
          as we are loading a taskInstance, where the taskId actually doesn;t exists... but jbpm doesn;t throw any exception when loading taskInstance.

          Shriram

          • 2. Re: Exception Handling  in JBPM
            send2shriram

            Is there any plans in future release of JBPM for handling these kind of errors properly?
            Throwing an RuntimeException like ObjectNotFoundException to user
            is not acceptable.

            Shriram

            • 3. Re: Exception Handling  in JBPM
              kirby

              The problem is that the load* istructions are probably implemented using the load method in Hibernate.
              The load method REQUIRES that the object exists before loading them, because it doesn't really do a DB fetch, just initialize a proxy object.
              When the proxy is resolved (at property access) an exception is thrown.

              I think that the best thing you can do is retrive the Hibernate Session from JbpmContext and issue a "session.get(classOfTheObjectYouRequire, id)", that actually do a DB fetch, and returns the object, or null if the object is not found.

              • 4. Re: Exception Handling  in JBPM
                send2shriram

                Hi kirby,

                Thanks for your reply. But still i have the same problem. Here is my code

                TaskInstance taskInstance = null;
                Session session = jbpmContext.getSession();

                taskInstance = (TaskInstance)session.load(TaskInstance.class,new Long (taskID));

                • 5. Re: Exception Handling  in JBPM
                  send2shriram


                  TaskInstance taskInstance = null;
                  Session session = jbpmContext.getSession();
                  taskInstance = (TaskInstance)session.load(TaskInstance.class,new Long (taskID));

                  Is this correct ?


                  Thanks
                  shriram

                  • 6. Re: Exception Handling  in JBPM
                    kirby

                    You have to use the get() method instead of the load() one, otherwise you'll get the same behaviour that you had before.

                    Just replace load with get, and verify the return value (will be null if no object is found).

                    • 7. Re: Exception Handling  in JBPM
                      send2shriram

                      Hi kirby,

                      It worked !!!!. Thanks a lot for helping me to
                      solve this problem. I have been worrying about handling this for over a week.

                      Thanks