<!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;">
    Different ClassLoader, ClassCastException
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/pseudoJBoss">Konrad Schuler</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/535208#535208">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,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>first, something to the background.</p><p>I try to run a simple BPMN 2.0 Process on jbpm-4.4-SNAPSHOT, where the user tasks can be handled by a Portlet (JSF, Facelets) on Liferay 5.2.3. The AS is JBoss 5.1.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The deployment of the Process I do as follows</p><pre class="jive-pre"><code class="jive-code jive-java">ProcessEngine pe=<font color="navy"><b>new</b></font> Configuration().buildProcessEngine();
RepositoryService repositoryService = pe.getRepositoryService();
NewDeployment deployment = repositoryService.createDeployment();
deployment.addResourceFromClasspath(<font color="red">"myprocess.bpmn.xml"</font>);
deployment.deploy();
</code></pre><p>and it works fine.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Than I start the process as follows</p><pre class="jive-pre"><code class="jive-code jive-java">Customer customer=<font color="navy"><b>new</b></font> Customer(<font color="red">"Firstname"</font>, <font color="red">"Lastname"</font>);
Map&lt;String, Object&gt; variables = <font color="navy"><b>new</b></font> HashMap&lt;String, Object&gt;();
variables.put(<font color="red">"customer"</font>, customer);
ProcessInstance pi = pe.getExecutionService().startProcessInstanceByKey(<font color="red">"myprocess"</font>, variables);
</code></pre><p>and it also works fine.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Than in a JSF Bean I wand to read the "customer" variable to handle a user task. So I do the following.</p><pre class="jive-pre"><code class="jive-code jive-java">String executionId=pe.getTaskService().getTask(currentTaskId).getExecutionId();
Customer customer=(Customer)pe.getExecutionService().getVariable(executionId, <font color="red">"customer"</font>);
</code></pre><p>And here I have a problem.</p><p>If the com.mycomp.Customer class is within my .war than there is a ClassNotFoundException .. com.mycomp.Customer...</p><p>If I put the com.mycomp.Customer class to the JBoss (global) libs, than there is a ClassCastException ... can not cast com.mycomp.Customer to com.mycomp.Customer ...</p><p>- I am sure that there is only one com.mycomp.Customer class within my JBoss</p><p>- And the com.mycomp.Customer class implements Serializable with a&#160; generated serial version id</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I think the problem is the different ClassLoader. After debugging I've found out that the ClassLoader of the class of</p><pre class="jive-pre"><code class="jive-code jive-java">pe.getExecutionService().getVariable(executionId, <font color="red">"customer"</font>)
&#160;
</code></pre><p>is BaseClassLoader@c94114{vfsfile:/C:/Programms/jboss-5.1.0.GA/server/default/conf/jboss-service.xml}</p><p>and the ClassLoader of</p><pre class="jive-pre"><code class="jive-code jive-java">Customer customer...
&#160;
</code></pre><p>is BaseClassLoader@12e43f8{vfsfile:/C:/Programms/jboss-5.1.0.GA/server/default/deploy/MyWebApp.war/}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So what can I do to solve the problem.</p><p>Thank you!!!</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/535208#535208">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>