ProcessClassLoader [ Urgent Help please !!!]
joshua_hj Jan 19, 2006 9:24 PMDear community,
I want to use jBPM inside of a servlet and i must serialize some variables to process instances. Currently i am using MySQL/Hinernate, JBoss-4.0.2 and JVM 1.5 and jbpm-3.0.2.
Well, as you know the web archive has an web/classes directory structure that must be used. My actions class do not have a classes.package name and that is confusing jbpm. ProcessClassLoader cannot find the actions classes inside the classes dir, but they are there. (???)
A work arround (still some problems...) is to deploy another jar file with the action classes. That way, jbpm can find the classes and it works fine if i dont use the serialization.
When i introduce some serializable variable to a process instance the process works fine until a new deployment. If a new redeploy is made i get a ClassCastException, complaining about the action classes. JBoss needs to shutdown fot the things to work again. This is a UnClassLoading issue i guess.
STATUS OK [When not using serialization]
The servlet retrieves the processdefinition from DB [OK]
I can signal the instance and i can see the process go through
nodes [OK]
When i serialize a simple object (3 String fields class) to a process instance it only works until a new redeploy and then i get a ClassCastException. If i start jboss again it gets OK again, until a new redeploy.
FILES:
file.war (containing the servlet)
file.jar (containing the actions classes (nodes))
Processdefinitoin.xml
<?xml version="1.0" encoding="UTF-8"?> <process-definition xmlns="http://jbpm.org/3/jpdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jbpm.org/3/jpdl http://jbpm.org/xsd/jpdl-3.0.xsd" name="ChangeNumber"> <start-state name="start"> <transition to="INIT" /> </start-state> <node name="INIT"> <action class='pt.ptinovacao.ngin.scp.smpsat.jbpm.classes.CN_Init_State' /> <transition to="SLRI" /> </node> <node name="SLRI"> <action class='pt.ptinovacao.ngin.scp.smpsat.jbpm.classes.CN_SLRi' /> <transition to="SLRE" /> </node> <node name="SLRE"> <action class='pt.ptinovacao.ngin.scp.smpsat.jbpm.classes.CN_SLRe' /> <transition to="SDPI" /> </node> <node name="SDPI"> <action class='pt.ptinovacao.ngin.scp.smpsat.jbpm.classes.CN_SDPi' /> <transition to="SDPE" /> </node> <node name="SDPE"> <action class='pt.ptinovacao.ngin.scp.smpsat.jbpm.classes.CN_SDPe' /> <transition to="end1" /> </node> <end-state name="end1"></end-state> </process-definition>
Serialization code
JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession(); // ... and begin a transaction on the persistence session jbpmSession.beginTransaction(); // Now we can query the database for the process definition that we // deployed above. ProcessDefinition processDefinition = jbpmSession.getGraphSession().findLatestProcessDefinition("ChangeNumber"); ProcessInstance pi = new ProcessInstance(processDefinition); System.out.println("[States]: " + pi.getProcessDefinition().getNodes()); ProcessWrapper pw = new ProcessWrapper(); pw.setOne("Smint1"); pw.setTwo("Smint2"); pw.setThree("Smint3"); pi.getContextInstance().setVariable("pw", pw); pi.signal(); System.out.println("[Process]: " + pi.getRootToken().getNode().getName());
Exception
02:09:49,939 ERROR [[SAPAdaptor]] Servlet.service() for servlet SAPAdaptor threw exception org.jbpm.graph.def.DelegationException at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:299) at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:293) at org.jbpm.graph.def.Node.execute(Node.java:299) at org.jbpm.graph.def.Node.enter(Node.java:284) at org.jbpm.graph.def.Transition.take(Transition.java:92) at org.jbpm.graph.def.Node.leave(Node.java:349) at org.jbpm.graph.node.StartState.leave(StartState.java:73) at org.jbpm.graph.exe.Token.signal(Token.java:127) at org.jbpm.graph.exe.Token.signal(Token.java:92) at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:201) at pt.ptinovacao.ftp.sapa.adaptor.SAPAServlet.doPost(SAPAServlet.java:145) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112) at java.lang.Thread.run(Thread.java:595) Caused by: java.lang.ClassCastException: pt.ptinovacao.ngin.scp.smpsat.jbpm.classes.ProcessWrapper at pt.ptinovacao.ngin.scp.smpsat.jbpm.classes.CN_Init_State.execute(CN_Init_State.java:37) at org.jbpm.graph.def.Action.execute(Action.java:79) at org.jbpm.graph.def.Node.execute(Node.java:295)
Thanks Joshua