Results 1 to 2 of 2

Thread: cannot be cast to org.jbpm.graph.def.ActionHandler

  1. #1
    Join Date
    May 2009
    Posts
    3

    Default cannot be cast to org.jbpm.graph.def.ActionHandler

    Hi,

    I have a very simple handler that gets invoked when the timer fires.

    Handler code:
    Code:
    import org.jbpm.graph.def.ActionHandler;
    import org.jbpm.graph.exe.ExecutionContext;
    
    public class OrderLockHandler implements ActionHandler {
    
            private static final long serialVersionUID = 1L;
    
    	public void execute(ExecutionContext executionContext) throws Exception
    	{
                  System.out.println("Inside OrderLockHandler::execute()");
    	}
    }
    This handler is inside a jar. I don't really know what is the proper way to deploy jars to the jboss server, so I copy this jar to
    C:\jboss\jbpm-jpdl-3.2.3\server\server\jbpm\lib directory and start the server.

    I create an instance of the process and when the timer fires, I receive the following exception:

    Code:
    Caused by: java.lang.ClassCastException: com.primolow.auction.jbpm.handler.OrderLockHandler cannot be cast to org.jbpm.graph.def.ActionHandler
            at org.jbpm.graph.def.Action.execute(Action.java:121)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
            at org.jbpm.graph.def.Action_$$_javassist_34.execute(Action_$$_javassist_34.java)
            at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:259)
    My only guess was to check that the version of jbpm-jpdl.jar in jboss is the same as the one I linked against in my handler jar. They were the same.

    Thanks for any help

  2. #2
    Join Date
    Feb 2009
    Posts
    5

    Default

    In cases where you get class cast exceptions using ActionHandler
    or Action, you should try to use delegation instead of casting.

    For example:

    Code:
    Node node = new Node("x");
    Event event = new Event(Event.EVENTTYPE_x);
    Delegation delegation = new Delegation("x.ActionHander");
    Action action = new Action(delegation);
    event.addAction(action);
    node.addEvent(event);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •