[jboss-user] [JBoss jBPM] - ClassCast Problem

Candersen do-not-reply at jboss.com
Wed Aug 29 06:16:09 EDT 2007


Hello,

I am encountering a strange problem. I wrote a very simple Processdefinition:


  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <process-definition
  |   xmlns="" name="objectTest">  
  |    <start-state name="start">
  |       <event type="node-leave">
  |          <action name="action1" class="com.test.SetUpActionHandler"/>
  |       </event>
  |       <transition name="" to="node1"></transition>     
  |    </start-state>               
  |       <end-state name="end">
  |       </end-state>
  |    <node name="node1">
  |       <action class="com.test.ObjectTestActionHandler" />
  |       <transition name="" to="end"></transition>
  |    </node>  
  | </process-definition>
  | 

In the SepUpActionHandler class I declare a simple TestObject and put it into the ContextInstance:

 
  | package com.test;
  | 
  | import org.jbpm.graph.def.ActionHandler;
  | import org.jbpm.graph.exe.ExecutionContext;
  | 
  | public class SetUpActionHandler implements ActionHandler {
  | 
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	public void execute(ExecutionContext executionContext) throws Exception
  | 	{
  | 		TestObject to = new TestObject();
  | 		to.setText("TestString");
  | 		executionContext.getContextInstance().setVariable("Test", to);
  | 	}
  | }
  | 

The TestObject itself is a very minimal serializable object:


  | package com.test;
  | 
  | import java.io.Serializable;
  | 
  | public class TestObject implements Serializable {
  | 
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	private String _text = "leer";
  | 	
  | 	public TestObject()
  | 	{
  | 		
  | 	}
  | 	
  | 	public String getText()
  | 	{
  | 		return _text;
  | 	}
  | 	
  | 	public void setText(String s)
  | 	{
  | 		_text = s;
  | 	}
  | }
  | 

And finally, in the ObjectTestActionHandler, I retrieve the TestObject from the ContextInstance:


  | package com.test;
  | 
  | import org.jbpm.graph.def.ActionHandler;
  | import org.jbpm.graph.exe.ExecutionContext;
  | 
  | public class ObjectTestActionHandler implements ActionHandler {
  | 
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	public void execute(ExecutionContext executionContext) throws Exception
  | 	{
  | 		Object o = executionContext.getContextInstance().getVariable("Test");
  | 		TestObject to = (TestObject) o;
  | 		
  | 		executionContext.getToken().signal();
  | 	}
  | }
  | 

When I execute this process in Eclipse, everything runs fine, there are no errors. But when I deploy it to a JBoss AS (4.0.4) and start it using the jbpm-web-console, I get a ClassCastException with the message: "com.test.TestObject cannot be cast to com.test.TestObject" 

The Exception is thrown by the ObjectTestActionHandler in the line where the casting is done:


  | TestObject to = (TestObject) o;
  | 

Does anybody know why this happens?

Regards,

Claus Andersen

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079077#4079077

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079077



More information about the jboss-user mailing list