[jboss-user] [jBPM] - Process Variable cannot be casted and accessed

Gerardo Navarro Suarez do-not-reply at jboss.com
Mon Apr 26 16:20:14 EDT 2010


Gerardo Navarro Suarez [http://community.jboss.org/people/GerardoNS] created the discussion

"Process Variable cannot be casted and accessed"

To view the discussion, visit: http://community.jboss.org/message/539622#539622

--------------------------------------------------------------
Hi All,

I'm having a problem to access a process variable in an ActionHandler. I've installed jBPM 3.2.3 (suite) and the GPD eclipse plugin, which is very nice for the deployment of the process and all its resources.

The problem appears in the jbpm-console when the token moves from state named "first" to the end-state "end". The transition fires and calls de.hpi.pois.GetterAction. The ActionHandler wants to acess the process variable "appli" and then the error appears. The process variable cannot be cast (see the attached errorLog). The jbpm-console displays the error message:"Error signalling token: An exception of type "org.jbpm.graph.def.DelegationException" was thrown. The message is: de.hpi.pois.klassen.Application cannot be cast to de.hpi.pois.klassen.Application".

I know that there is already a thread ( http://community.jboss.org/message/377445#377445 http://community.jboss.org/message/377445#377445) dealing with almost the same problem, but this discussion doesn't come to an end. I hope that this discussion will get a result. Maybe you'll have an idea.

It's only a guess, but maybe there are some configurations missing (maybe for the hibernate, I don't know). To deploy the process I use the deployment tab provided by the GPD eclipse plugin (see GPDt.png). I wonder how experts deploy their processes? Maybe I'm doing something wrong.

I've prepared a little process for this thread which reproduces the problem. My main project is a bit bigger, but there happens the same problem.


My processdefiniton.xml:

<process-definition 
  xmlns="urn:jbpm.org:jpdl-3.2"
  name="simple">
   <start-state name="start">
        <transition to="first" name="to_state">
            <action name="actoin1" class="de.hpi.pois.action.ApplicationCreation"></action>
        </transition>
    </start-state>
   <state name="first">
      <transition name="to_end" to="end">
         <action name="action2" class="de.hpi.pois.action.GetterAction"></action>
      </transition>
   </state>
   <end-state name="end"></end-state>
</process-definition>


The ActionHandler ApplicationCreation:

package de.hpi.pois.action;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import de.hpi.pois.klassen.Application;

public class ApplicationCreation implements ActionHandler
{
    private static final long serialVersionUID = 1893405813471405736L;

    @Override
    public void execute(ExecutionContext arg0) throws Exception
    {
        Application appli = Application.createApplication("Gerardo, mailto:g at hpi.de g at hpi.de");

        arg0.setVariable("appli", appli);
    }

}


The ActionHandler GetterAction:

package de.hpi.pois.action;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import de.hpi.pois.klassen.Application;

public class GetterAction implements ActionHandler
{
    private static final long serialVersionUID = -7981154292715474830L;

    @Override
    public void execute(ExecutionContext arg0) throws Exception
    {
        Application appli = (Application) arg0.getVariable("appli");

        arg0.setVariable("name", appli.getName());
        arg0.setVariable("email", appli.getEmail());
    }

}


The class Applicaion:

package de.hpi.pois.klassen;

import java.io.Serializable;

public class Application implements Serializable
{
    private static final long serialVersionUID = 134598365872315L;
    
    public String name;
    public String email; 
    
    public Application(){}
    
    public Application(String name, String email)
    {
        setName(name);
        setEmail(email);
    }
    
    public static Application createApplication(String entry)
    {
        String[] entryElements = entry.split(",");
        
        return new Application(entryElements[0], entryElements[1]);
    }
    
    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEmail() {
        return email;
    }
}

Thanks fro your help. I appreciate it a lot.

Greetings,

Gerardo

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/539622#539622]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100426/66e12ba4/attachment.html 


More information about the jboss-user mailing list