2 Replies Latest reply on Mar 6, 2013 9:56 AM by Feki Ahmed

    jbpm 5.4.0 - NullPointerException completing workItem. is this bug not resolved yet ?

    Feki Ahmed Newbie

      i think that i have the same issue then in here which seems to be a bug in jbpm 5.4.

       

      i had the same exception when trying to complete a workitem after a session reload,

      By the way, i coudn't get a processInstance using  :processInstance = ksession.getProcessInstance(processInstance.getId()); from the reloaded Session, i also wish to know why.

      even the ksession.getProcessInstances() is empty !)

       

      i have to mention that the task status is "completed" in the database even when this exception happens but the process do not continue to the next task.

       

      this is the log for it the exception:

       

       

      (SingleSessionCommandService.java:400) ERROR org.drools.persistence.SingleSessionCommandService - Could not commit session

      java.lang.NullPointerException

                at org.jbpm.process.instance.impl.ProcessInstanceImpl.setProcess(ProcessInstanceImpl.java:62)

                at org.jbpm.marshalling.impl.AbstractProtobufProcessInstanceMarshaller.readProcessInstance(AbstractProtobufProcessInstanceMarshaller.java:375)

                at org.jbpm.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:142)

                at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:91)

                at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:206)

                at org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1116)

                at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:297)

                at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:117)

                at org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:69)

                at org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:32)

                at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:373)

                at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150)

                at ManagedBeans.JbpmAPIUtil.StartAndCompleteTask(JbpmAPIUtil.java:372)

                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.el.parser.AstValue.invoke(AstValue.java:264)

                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

                at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)

                at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:450)

                at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)

                at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)

                at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760)

                at javax.faces.component.UICommand.broadcast(UICommand.java:300)

                at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

                at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)

                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)

                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

                at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)

                at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)

                at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)

                at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1770)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                at java.lang.Thread.run(Unknown Source)

       

       

       

      Thanks for help !!!

        • 1. Re: jbpm 5.4.0 - NullPointerException completing workItem. is this bug not resolved yet ?
          Shobhit Tyagi Master

          How do you load the knowledge base for creating the session??

          1 of 1 people found this helpful
          • 2. Re: jbpm 5.4.0 - NullPointerException completing workItem. is this bug not resolved yet ?
            Feki Ahmed Newbie

            You are pointing to the right place ! i resolved this problem and i remember that i had to instanciate a new kbuilder, a new  kbase ,a new  env , a new  emf for the session to reload as it is a new created session and even a new client for dealing with tasks.

             

            here is the code :

             

            KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

                    kbuilder.add(new ClassPathResource(proctoreloadname+".bpmn"), ResourceType.BPMN2);

             

             

                    if (kbuilder.hasErrors()) {

                        for (KnowledgeBuilderError error : kbuilder.getErrors()) {

                            System.out.println(">>> Error:" + error.getMessage());

             

             

                        }

                        System.out.println(">>> Knowledge couldn't be parsed! ");

                    }

             

             

                    kbase = KnowledgeBaseFactory.newKnowledgeBase();

             

             

                    kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());

                    env = EnvironmentFactory.newEnvironment();

                    emf = Persistence.createEntityManagerFactory("org.jbpm.runtime.ht");

                    env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                    env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager());

             

             

             

                    processInstance = null;

             

             

                           // Let's reload the session

                              ksessions.add(JPAKnowledgeService.loadStatefulKnowledgeSession(Integer.parseInt(idSessionToReload), kbase, null, env));

                              ksessions.remove(ksessions.size()-2);

                             

                              sessionId= ksessions.get(ksessions.size()-1).getId();

                              // All the listeners and WorkItemHandlers are volatile, so we need to register them each time that we reload the session

                              //  from the DB.

                              clients.add(createTaskService(emf));

                              clients.remove(clients.size()-2);

                              clients.get(clients.size()-1).connect();

                              localHTWorkItemHandlers.add(new LocalHTWorkItemHandler(clients.get(clients.size()-1), ksessions.get(ksessions.size()-1)));

                              localHTWorkItemHandlers.remove(localHTWorkItemHandlers.size()-2);

                              try {

                                                    clients.get(clients.size()-1).disconnect();

                                          } catch (Exception e1) {

                                                    // TODO Auto-generated catch block

                                                    e1.printStackTrace();

                                          }

                             

                              ksessions.get(ksessions.size()-1).getWorkItemManager().registerWorkItemHandler("Human Task", localHTWorkItemHandlers.get(localHTWorkItemHandlers.size()-1));