2 Replies Latest reply on Oct 28, 2005 10:57 AM by kukeltje

    NullPointerException with task assignment

    tobysaville

      When i execute the following JUnit Test Case:

       public void testTaskAssignment(){
      
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
       "<process-definition name='the baby process'>" +
       " <start-state>" +
       " <transition name='baby cries' to='t' />" +
       " </start-state>" +
       " <task-node name='t'>" +
       " <transition to='end' />" +
       " </task-node>" +
       " <end-state name='end' />" +
       "</process-definition>"
       );
      
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
      
       Token token = processInstance.getRootToken();
      
       token.signal();
      
       try{
       TaskInstance tInstance = (TaskInstance) processInstance.
       getTaskMgmtInstance().
       getTaskInstances().
       iterator().
       next();
      
       tInstance.end();
       }catch(NullPointerException npe){
       System.out.println("No tasks");
       }
       }
      


      Everything works ok (there are no task instances, but thats ok). However, when i add the following lines to the process definition XML:

      " <task name='change nappy'>" +
      " <assignment class='com.test.MyAssigHandler' />" +
      " </task>" +
      


      I get the following exception:

      java.lang.NullPointerException
       at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at org.jbpm.instantiation.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:16)
       at org.jbpm.taskmgmt.exe.TaskMgmtInstance.getTaskInstanceClass(TaskMgmtInstance.java:41)
       at org.jbpm.taskmgmt.exe.TaskMgmtInstance.instantiateNewTaskInstance(TaskMgmtInstance.java:174)
       at org.jbpm.taskmgmt.exe.TaskMgmtInstance.createTaskInstance(TaskMgmtInstance.java:74)
       at org.jbpm.graph.node.TaskNode.execute(TaskNode.java:136)
       at org.jbpm.graph.def.Node.enter(Node.java:284)
       at org.jbpm.graph.def.Transition.take(Transition.java:92)
       at org.jbpm.graph.def.Node.leave(Node.java:349)
       at org.jbpm.graph.node.StartState.leave(StartState.java:73)
       at org.jbpm.graph.exe.Token.signal(Token.java:127)
       at org.jbpm.graph.exe.Token.signal(Token.java:92)
       at com.qas.newmedia.intranet.oem.test.TestTaskAssignment.testTaskAssignment(TestTaskAssignment.java:32)
       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 junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
       at junit.framework.TestResult$1.protect(TestResult.java:106)
       at junit.framework.TestResult.runProtected(TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run(TestSuite.java:203)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      


      The NullPointer is raised when on the line that i call

      token.signal();
      


      Is there any reason this might be?

      Thanks,

      toby

        • 1. Re: NullPointerException with task assignment
          tobysaville

          Incase anyone comes across this problem, this is the answer:

          You need to add the following line to your jbm.properties file:

          jbpm.task.instance.class=org.jbpm.taskmgmt.exe.TaskInstance
          


          It couldnt find the class definition to use as a TaskInstance. The doco says there is a default, but if there is no declaration in the properties file, it throws a NullPointerException in the ClassLoaderUtil class when trying to load class with a null name value (called from TaskMgmtInstance on line 41)

          toby

          • 2. Re: NullPointerException with task assignment
            kukeltje

            afaik there is aq default IF the jbpm.taskinstance.class property is not in the config. If it is and it has no value yes... then I can imagine the NPE (should be caught btw)