4 Replies Latest reply on Mar 3, 2006 1:06 AM by johndannerpsu

    ClassLoader issue with jBPM and EJB3+EAR deployment?

      I am relatively to JBoss/jBPM but have been having good sucess with it so far. However I have just hit a problem that has had me stumped for the better part of a day now.

      I am using:

      - jboss-EJB-3.0_RC5-PFD
      - jbpm-3.1
      - jboss-4.0.4RC1

      Most of it works fine, except I am having trouble with the execution of a jBPM process invoked from a @Stateless session bean.

      I have a process definition deployed into my database that I can successfully invoke from a method in the stateless session bean. However if I attempt to trigger a custom ActionHandler from the process, jBPM complains that it cannot find the action handler class.

      Here is an extract of my processdefinition.xml file:

       <start-state name="start">
       <transition name="" to="Invoke Call"></transition>
       </start-state>
       <state name="Invoke Call">
       <event type="node-enter">
       <action name="createCall" config-type="field" class="com.vieo.ccs.process.actions.CreateCallActionHandler" />
       </event>
       <transition name="ACTIVE" to="Setup Success"></transition>
       </state>
      


      The exception I am getting is as follows:


      18:30:00,156 ERROR [GraphElement] action threw exception: couldn't get value for file 'classes/com/vieo/ccs/process/actions/CreateCallActionHandler.class' org.jbpm.JbpmException: couldn't get value for file 'classes/com/vieo/ccs/process/actions/CreateCallActionHandler.class'
      at org.jbpm.file.def.FileDefinition.getBytes(FileDefinition.java:186)
      at org.jbpm.instantiation.ProcessClassLoader.findClass(ProcessClassLoader.java:55)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      at org.jbpm.instantiation.Delegation.instantiate(Delegation.java:140)
      at org.jbpm.instantiation.Delegation.getInstance(Delegation.java:125)
      at org.jbpm.instantiation.Delegation$$FastClassByCGLIB$$6bae1598.invoke(<generated>)
      at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
      at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
      at org.jbpm.instantiation.Delegation$$EnhancerByCGLIB$$1e6cb7ea.getInstance(<generated>)
      at org.jbpm.graph.def.Action.execute(Action.java:122)
      at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235)
      at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:212)
      ...
      <stuff cut>
      ...
      Caused by: org.jbpm.JbpmException: file 'classes/com/vieo/ccs/process/actions/CreateCallActionHandler.class' not found in db
      ...
      <more stuff cut>
      ...
      18:30:00,156 ERROR [StartProcessActionHandlerBean] JBPMException: org.jbpm.graph.def.DelegationException



      Now, to me this looks like jBPM cannot find my ActionHandler class (com.vieo.ccs.process.actions.CreateCallActionHandler) so I wrote a little bit of code in my stateless session bean to test it:

       try {
       ClassLoader classloader = this.getClass().getClassLoader();
       Class systemC = classloader.loadClass("com.vieo.ccs.process.actions.CreateCallActionHandler");
       logger.info("Loaded system class: " + systemC);
       } catch (ClassNotFoundException e) {
       logger.error("Error system class loader! : " + e);
       }
       try {
       // Test org.jbpm.util.ClassLoaderUtil
       Class jbpmC = ClassLoaderUtil.loadClass("com.vieo.ccs.process.actions.CreateCallActionHandler");
       if( jbpmC != null ) {
       logger.info("Loaded jbpm class: " + jbpmC);
       } else {
       logger.info("Loaded jbpm class: null");
       }
       } catch (JbpmException e) {
       logger.error("Error jbpm class loader! : " + e);
       }
      


      And sure enough, I can successfully access this class from my code, but for some reason if I use the jBPM ClassLoader then it cannot be found!

      Here is the output:


      18:30:00,109 INFO [StartProcessActionHandlerBean] Loaded system class: class com.vieo.ccs.process.actions.CreateCallActionHandler
      18:30:00,125 ERROR [StartProcessActionHandlerBean] Error jbpm class loader! : org.jbpm.JbpmException: class not found 'com.vieo.ccs.process.actions.CreateCallActionHandler'


      My understanding is that, for some reason, jBPM cannot access my classes (which are currently deployed as a .jar within my .ear package).

      How do I make the classes in my .ear visible to the installed jBPM instance? (jBPM was installed using 'ant -f build.deploy.xml create.jbpm.configuration' and I'm using the jbpm JBoss configuration).

      Thanks for your help!

        • 1. Re: ClassLoader issue with jBPM and EJB3+EAR deployment?

          OK after sleeping on it and having another look in the morning I found the problem!

          It turns out I accidently had a jboss-app.xml file included in my .ear file which was enabling scoped class loading via a <loader-repository> tag.

          Remove this file from the .ear and magically everything works!

          Presumably having an isolated deployment means that jBPM can't see my classes, which I guess is the intention of this feature? Does anyone know if it is possible to use custom jBPM action handlers with isolated deployments?

          For my purposes I don't need isolated deployments for the time being so it is not a problem, but for anyone else who is having ClassLoader difficulties check out: http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

          • 2. Re: ClassLoader issue with jBPM and EJB3+EAR deployment?
            johndannerpsu

            scotto,

            I'm having the same issue that you had. I've check my ear file and don't have a jboss-app.xml file so I don't think I'm overriding the default behaviour that is current set in ear-deployer.xml. In that file has the following for isolation:

            false


            The system can load the class via your test code but much like your setup jBPM cannot. Can you think of anything else you may have changed to get this to work?

            AS: JBoss 4.0.3 (the jbpm-starter-kit for v3.1)

            Thanks!

            -John

            • 3. Re: ClassLoader issue with jBPM and EJB3+EAR deployment?
              johndannerpsu

              Nice ---

              The values are actually:

              
              <attribute name="Isolated">false</attribute>
              <attribute name="CallByValue">false</attribute>
              
              


              • 4. Re: ClassLoader issue with jBPM and EJB3+EAR deployment?
                johndannerpsu

                Ok, instead of going that route I have another solution (thanks to another post in this forum).

                I removed the jbpm.sar directory and the jbpm.war file from the delpoy directory.

                I then copied the JAR files from the jbpm.sar dir into WEB-INF/lib in my .war file. I then deploy the war and everything is working.