<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Process Variable cannot be casted and accessed
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/GerardoNS">Gerardo Navarro Suarez</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/539622#539622">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi All,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span>I know that there is already a thread (</span><a class="jive-link-external-small" href="http://community.jboss.org/message/377445#377445" target="_blank">http://community.jboss.org/message/377445#377445</a><span>) 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.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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.</p><p><span style="text-decoration: underline;"><br/></span></p><p><span style="text-decoration: underline;">My processdefiniton.xml:</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><process-definition <br/>  xmlns="urn:jbpm.org:jpdl-3.2"<br/>  name="simple"><br/>   <start-state name="start"><br/>        <transition to="first" name="to_state"><br/>            <action name="actoin1" class="de.hpi.pois.action.ApplicationCreation"></action><br/>        </transition><br/>    </start-state><br/>   <state name="first"><br/>      <transition name="to_end" to="end"><br/>         <action name="action2" class="de.hpi.pois.action.GetterAction"></action><br/>      </transition><br/>   </state><br/>   <end-state name="end"></end-state><br/></process-definition></p><p><span style="text-decoration: underline;"><br/></span></p><p><span style="text-decoration: underline;">The ActionHandler ApplicationCreation:</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>package de.hpi.pois.action;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.jbpm.graph.def.ActionHandler;</p><p>import org.jbpm.graph.exe.ExecutionContext;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import de.hpi.pois.klassen.Application;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>public class ApplicationCreation implements ActionHandler</p><p>{</p><p>    private static final long serialVersionUID = 1893405813471405736L;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    @Override</p><p>    public void execute(ExecutionContext arg0) throws Exception</p><p>    {</p><p><span>        Application appli = Application.createApplication("Gerardo,</span><a class="jive-link-email-small" href="mailto:g@hpi.de" target="_blank">g@hpi.de</a><span>");</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        arg0.setVariable("appli", appli);</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p><p><span style="text-decoration: underline;"><br/></span></p><p><span style="text-decoration: underline;">The ActionHandler GetterAction:</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>package de.hpi.pois.action;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.jbpm.graph.def.ActionHandler;</p><p>import org.jbpm.graph.exe.ExecutionContext;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import de.hpi.pois.klassen.Application;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>public class GetterAction implements ActionHandler</p><p>{</p><p>    private static final long serialVersionUID = -7981154292715474830L;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    @Override</p><p>    public void execute(ExecutionContext arg0) throws Exception</p><p>    {</p><p>        Application appli = (Application) arg0.getVariable("appli");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        arg0.setVariable("name", appli.getName());</p><p>        arg0.setVariable("email", appli.getEmail());</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p><p><span style="text-decoration: underline;"><br/></span></p><p><span style="text-decoration: underline;">The class Applicaion:</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>package de.hpi.pois.klassen;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import java.io.Serializable;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>public class Application implements Serializable<br/>{<br/>    private static final long serialVersionUID = 134598365872315L;<br/>    <br/>    public String name;<br/>    public String email; <br/>    <br/>    public Application(){}<br/>    <br/>    public Application(String name, String email)<br/>    {<br/>        setName(name);<br/>        setEmail(email);<br/>    }<br/>    <br/>    public static Application createApplication(String entry)<br/>    {<br/>        String[] entryElements = entry.split(",");<br/>        <br/>        return new Application(entryElements[0], entryElements[1]);<br/>    }<br/>    <br/>    public void setName(String name) {<br/>        this.name = name;<br/>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    public String getName() {<br/>        return name;</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    public void setEmail(String email) {<br/>        this.email = email;<br/>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    public String getEmail() {<br/>        return email;<br/>    }<br/>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thanks fro your help. I appreciate it a lot.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Greetings,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Gerardo</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/539622#539622">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>