3 Replies Latest reply on Oct 5, 2006 7:58 PM by leonel_vr

    HelloTest NullPointer Exception

      Hello all,

      I am running the tutorials in A Guided Tour of JBoss jBPM GPD. In chapter 3, Test Driven Process Development, rRunning the JUnit test results in a NullPointerException on line 12. Do I need to set a location anywhere to point to the process definition xml file? Any help to to get me past this is appreciated.

      Here is the error when Running JUnit from Eclipse. It looks to me like it can't find the process defininition XML file.

      java.lang.NullPointerException
      at java.io.Reader.(Unknown Source)
      at java.io.InputStreamReader.(Unknown Source)
      at org.jbpm.graph.def.ProcessDefinition.parseXmlInputStream(ProcessDefinition.java:136)
      at org.jbpm.graph.def.ProcessDefinition.parseXmlResource(ProcessDefinition.java:128)
      at com.jbay.HelloTest.testProcess(HelloTest.java:12)
      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)


      Listed below is the source for HelloTest. line 12 is where the instance definition is instantiated.

      package com.jbay;

      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ProcessInstance;

      import junit.framework.TestCase;

      public class HelloTest extends TestCase {

      public void testProcess() throws Exception {
      //create a jBPM process archive object is created
      ProcessDefinition definition = ProcessDefinition.parseXmlResource("hello/processdefinition.xml"); //line 12 assertNotNull("Definition should not be null", definition);

      ProcessInstance instance = new ProcessInstance(definition);
      assertEquals ("Instance= start state", instance.getRootToken().getNode().getName(), "start");
      instance.signal();
      assertEquals( "Instance= auction state", instance.getRootToken().getNode().getName(), "auction");
      instance.signal();
      assertEquals( "Instance= end state", instance.getRootToken().getNode().getName(), "end1");
      assertTrue( "Instance has ended", instance.hasEnded());
      }
      }


      Listed below is the XML for the process definition

      ?xml version="1.0" encoding="UTF-8"?>

      <process-definition
      xmlns="http://jbpm.org/3/jpdl" name="jbay">
      <start-state name="start">

      </start-state>



      <end-state name="end1"></end-state>
      </process-definition>


      out of curiosity, why don't I see the .par extension in eclipse.
      is any other diagnostic information needed?

      Thank you in advance for your help.

      - andy

        • 1. Re: HelloTest NullPointer Exception
          ncapito

          What does your directory set up look like? Where is the hello directory located with respect to where you are running the test?

          • 2. Re: HelloTest NullPointer Exception

            I had the same problem on that step (and many problems on the other steps)
            and just wound up using the fully qualified path from root, and ti was happy with that.

            Holler if you run into tht rest fo the problems :}

            There is another thread open with my chapter 4 problems.
            http://www.jboss.org/index.html?module=bb&op=viewtopic&t=87003

            James Ratcliff

            • 3. Re: HelloTest NullPointer Exception
              leonel_vr

              this is what i did ...

              public class HelloTest extends TestCase {

              public void testProcess() throws Exception
              {
              //JpdlXmlReader.parseFromResource("Hello/processdefintion.xml");
              //ProcessDefinition definition=ProcessDefinition.parseParResource("Hello/processdefinition.xml");
              //assertNotNull("Definition should not be null",definition);

              // Extract a process definition from the processdefinition.xml file.
              FileInputStream fis = new FileInputStream("processes/Hello/processdefinition.xml");
              ProcessDefinition definition = ProcessDefinition.parseXmlInputStream(fis);
              assertNotNull("Definition should not be null", definition);


              ProcessInstance instance = new ProcessInstance(definition);
              assertEquals("Instance is in start state", instance.getRootToken().getNode().getName(),"start");

              instance.signal();
              assertEquals("Instance is in auction state", instance.getRootToken().getNode().getName(),"auction");

              instance.signal();
              assertEquals("Instance is in end state", instance.getRootToken().getNode().getName(),"end1");

              assertTrue("Instance has ended",instance.hasEnded());

              }


              }