3 Replies Latest reply on Oct 20, 2006 12:37 PM by gmournos

    Help:type of nodes returned by root.getNode() is unnarrowed


      I have created a custom node type and I need to cast to it during the workflow execution.
      However, when I cast the result of calling token.getNode() to my custom type, I get a ClassCastException, although the token is at my custom node at the time.

      My code is complicated so I created a simple test case, and added it to the already existing GraphSessionDbTest.java (basically I just added three assertions to the existing test case).
      The test case breaks, in the third assertion. The node has name 's' but it is not an instance of StartState...

      // added to jbpm-3.1/src/java.jbpm.test/org/jbpm/db/GraphSessionDbTest.java
       public void testUpdateProcessInstance2() {
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
       "<process-definition>" +
       " <start-state name='s' />" +
       " <node name='n' />" +
       processDefinition = saveAndReload(processDefinition);
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       processInstance = saveAndReload(processInstance);
       long pid = processInstance.getId();
       //this is the actual part added to the already existing testUpdateProcessInstance() case
       assertTrue(processInstance.getRootToken().getNode() instanceof Node);
       assertTrue(processInstance.getRootToken().getNode() instanceof StartState);
       assertEquals("s", processInstance.getRootToken().getNode().getName());
       processInstance = saveAndReload(processInstance);
       assertEquals("n", processInstance.getRootToken().getNode().getName());
       assertEquals(pid, processInstance.getId());

      Is this normal?
      I am not a hibernate expert.
      In my normal code (not when I am running the simple test case), during the execution of signal() I get hibernate warnings of the type:

      14:01:34,429 [main] WARN StatefulPersistenceContext : Narrowing proxy to class org.jbpm.graph.node.StartState - this operation breaks ==

      Are these relevant?