4 Replies Latest reply on Jul 18, 2006 3:15 AM by kukeltje

    NullpointerException at ProcessInstance.signal()

    bdepaz

      Hi,

      I'm having a problem trying to signal a process for further execution. I'm running jBPM in a J2EE environment (on an OC4J for that matter).
      I'm having a MessageDrivenBean triggering a ProcessInstance for further execution, however it seems like the Token is not having a ProcessInstance. How is that possible?

      I've implemented as described in the userguide:

      JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
      JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
      GraphSession graphSession = jbpmContext.getGraphSession();
      ProcessInstance pi = graphSession.loadProcessInstance(processId);
      process.signal();
      


      Output for that code is:
      java.lang.NullPointerException
       at org.jbpm.graph.exe.Token.startCompositeLog(Token.java:306)
       at org.jbpm.graph.exe.Token.signal(Token.java:167)
       at org.jbpm.graph.exe.Token.signal(Token.java:123)
       at org.jbpm.graph.exe.Token$$FastClassByCGLIB$$74df1c6e.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
       at org.jbpm.graph.exe.Token$$EnhancerByCGLIB$$7e7b07a8.signal(<generated>)
       at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:217)
       at org.jbpm.graph.exe.ProcessInstance$$FastClassByCGLIB$$5167cc59.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
       at org.jbpm.graph.exe.ProcessInstance$$EnhancerByCGLIB$$fb69fd53.signal(<generated>)
       at be.cm.health.tpb.process.MetroplanInvoiceWorkflow.unlockMetroplanInstance(MetroplanInvoiceWorkflow.java:105)
       at be.cm.health.tpb.integrators.MetroplanListener.onMessage(MetroplanListener.java:58)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
       at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
       at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
       at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
       at com.evermind.server.ejb.interceptor.system.SetContextActionInterceptor.invoke(SetContextActionInterceptor.java:34)
       at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
       at com.evermind.server.ejb.MessageDrivenConsumer.onMessage(MessageDrivenConsumer.java:344)
       at com.evermind.server.ejb.MessageDrivenConsumer.processMessages(MessageDrivenConsumer.java:230)
       at com.evermind.server.ejb.MessageDrivenConsumer.run(MessageDrivenConsumer.java:168)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:814)
       at java.lang.Thread.run(Thread.java:595)
      


      Now I've been debugging on that. The ProcessInstance is actually being returned, however, the ProcessInstance.token.processinstance is empty which is throwing the nullpointer here. (it needs it to get the LogginInstance).

      Am I doing something wrong here? I've been trying to get the token in other ways, but so far that wasn't very successfull :-S.

      my jbpm config:
      <jbpm-configuration>
       <jbpm-context>
       <service name="persistence">
       <factory>
       <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
       <field name="isTransactionEnabled">
       <false />
       </field>
       </bean>
       </factory>
       </service>
       <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
       <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
       <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
       <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
       </jbpm-context>
      </jbpm-configuration>
      


      Sincerely appreciate all the help...

      kind regards,
      Bert

        • 1. Re: NullpointerException at ProcessInstance.signal()
          bradtwurst

          I am also encountering this issue.

          Is there anything that I can do to help debug this issue.

          I am encountering the NPE in line 295 (addLog function) of the Token class. The processInstance is not being populated. However, the getProcessInstance does return a non-null value.

          I create the processInstance in one function and later in the application, I retrieve the token (based upon a passed tokenId) to signal the token.

          Thanks,
          James

          • 2. Re: NullpointerException at ProcessInstance.signal()
            kukeltje

            Bert,

            In your code

            JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
            JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
            GraphSession graphSession = jbpmContext.getGraphSession();
            ProcessInstance pi = graphSession.loadProcessInstance(processId);
            process.signal();


            You fill pi with the instance, but use process.signal(). A typo or the real cause? (I think the former)

            What is needed here is a full unit test to show the behaviour. That way we can simulate etc.... Besides that post ALL relevant info on your environment (jbpm version, jdk etc)

            • 3. Re: NullpointerException at ProcessInstance.signal()
              bdepaz

              Ronald,

              The pi - process was a typo indeed, sorry about that :-)

              However, you set me on the right path in order to find my error: basically i took the sample database unit test from the userguide and just copied my custom code in that until I noticed any difference.

              What I did wrong: I neglected to call the jbpmContext.save() and jbpmContext.close() method in my business methods. I did this because I previously stumbled upon some transaction conflicts running in J2EE environment. I assumed these were not necessairy when running with JTA enabled.
              Presumably, I was wrong :-)

              I beleive that was the main cause of my error here.

              Thanks for your time!
              Bert

              • 4. Re: NullpointerException at ProcessInstance.signal()
                kukeltje

                That would have been my second suggestion. Great that it works now and thanks for reporting back