3 Replies Latest reply on Apr 6, 2010 1:50 PM by swiderski.maciej

    Different ClassLoader, ClassCastException

      Hi,

       

      first, something to the background.

      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.

       

      The deployment of the Process I do as follows

      ProcessEngine pe=new Configuration().buildProcessEngine();
      RepositoryService repositoryService = pe.getRepositoryService();
      NewDeployment deployment = repositoryService.createDeployment();
      deployment.addResourceFromClasspath("myprocess.bpmn.xml");
      deployment.deploy();
      

      and it works fine.

       

      Than I start the process as follows

      Customer customer=new Customer("Firstname", "Lastname");
      Map<String, Object> variables = new HashMap<String, Object>();
      variables.put("customer", customer);
      ProcessInstance pi = pe.getExecutionService().startProcessInstanceByKey("myprocess", variables);
      

      and it also works fine.

       

      Than in a JSF Bean I wand to read the "customer" variable to handle a user task. So I do the following.

      String executionId=pe.getTaskService().getTask(currentTaskId).getExecutionId();
      Customer customer=(Customer)pe.getExecutionService().getVariable(executionId, "customer");
      

      And here I have a problem.

      If the com.mycomp.Customer class is within my .war than there is a ClassNotFoundException .. com.mycomp.Customer...

      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 ...

      - I am sure that there is only one com.mycomp.Customer class within my JBoss

      - And the com.mycomp.Customer class implements Serializable with a  generated serial version id

       

      I think the problem is the different ClassLoader. After debugging I've found out that the ClassLoader of the class of

      pe.getExecutionService().getVariable(executionId, "customer")
      

      is BaseClassLoader@c94114{vfsfile:/C:/Programms/jboss-5.1.0.GA/server/default/conf/jboss-service.xml}

      and the ClassLoader of

      Customer customer...
      

      is BaseClassLoader@12e43f8{vfsfile:/C:/Programms/jboss-5.1.0.GA/server/default/deploy/MyWebApp.war/}

       

      So what can I do to solve the problem.

      Thank you!!!