HelloTest NullPointer Exception
efhajg0 Jul 3, 2006 12:23 PMHello 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