ClassLoader issue with jBPM and EJB3+EAR deployment?
scotto Mar 2, 2006 6:08 AMI 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!