5 Replies Latest reply on Oct 31, 2005 11:43 AM by pedro costa

    org.jbpm.graph.def.DelegationException

    pedro costa Apprentice

      I've the following code:

      package com.sample;
      
      import junit.framework.TestCase;
      
      import org.jbpm.graph.def.*;
      import org.jbpm.graph.exe.*;
      import org.jbpm.taskmgmt.exe.*;
      //import com.sample.action.GravarOcorrenciaHandler;
      
      
      public class GestaoOcorrencias extends TestCase {
      
       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'>" +
       " <task name='change nappy'>" +
       " <assignment class='com.sample.action.GravarOcorrenciaHandler' />" +
       " </task>" +
       " <transition to='end' />" +
       " </task-node>" +
       " <end-state name='end' />" +
       "</process-definition>"
       );
      
      
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       Token token = processInstance.getRootToken();
      
       token.signal();
      
       assertSame(processDefinition.getNode("t"), token.getNode());
       TaskInstance taskInstance = (TaskInstance)
       processInstance
       .getTaskMgmtInstance()
       .getTaskInstances()
       .iterator().next();
      
       assertEquals("papa", taskInstance.getActorId() );
      
       taskInstance.end();
      
       assertSame(processDefinition.getNode("end"), token.getNode());
       }
      }
      



      package com.sample.action;
      
      import org.jbpm.graph.exe.ExecutionContext;
      import org.jbpm.taskmgmt.exe.Assignable;
      
      public class GravarOcorrenciaHandler {
       public void assign(Assignable assignable, ExecutionContext executionContext)
       {
       assignable.setActorId("papa");
       System.out.println("SUCCESS");
       }
      }
      [\code]
      
      
      When i compile it, i've
      
      org.jbpm.graph.def.DelegationException at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:299) at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:293) at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:293) at org.jbpm.taskmgmt.exe.TaskMgmtInstance.invokeAssignmentHandler(TaskMgmtInstance.java:149) at org.jbpm.taskmgmt.exe.TaskInstance.assign(TaskInstance.java:137) at org.jbpm.taskmgmt.exe.TaskMgmtInstance.createTaskInstance(TaskMgmtInstance.java:102)
       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.sample.GestaoOcorrencias.testTaskAssignment(GestaoOcorrencias.java:34)
       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)
      Caused by: java.lang.ClassCastException: com.sample.action.GravarOcorrenciaHandler
       at org.jbpm.taskmgmt.exe.TaskMgmtInstance.invokeAssignmentHandler(TaskMgmtInstance.java:141)
       ... 25 more
      
      What is wrong? Can anybody explain the reason for this exception, and what has to be done to solve this?
      This example is a copy of Task assignment example in http://docs.jboss.com/jbpm/v3/userguide/tutorial.html#helloworldexample
      
      Thanks,