9 Replies Latest reply on Aug 18, 2006 4:59 PM by aguizar

    ProcessClassLoader [ Urgent Help please !!!]

    joshua_hj

      Dear 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


        • 1. Re: ProcessClassLoader [ Urgent Help please !!!]
          ralfoeldi

          Hi Joshua,

          does your ProcessWrapper have a serialVersionUID? If not try setting one.

          But then, why do you need a ProcessWrapper? Why not set the variables dircetly, then you don't have a problem.

          Greetings

          Rainer

          • 2. Re: ProcessClassLoader [ Urgent Help please !!!]
            ummadiravi78

            For serialization, you should have created appropriate sub-classes of variableinstance and variableupdatelog and hibernate hbm.xml files . Also an entry into jbpm.varmapping.properties. Right?

            Could you please post them?

            • 3. Re: ProcessClassLoader [ Urgent Help please !!!]
              joshua_hj

              Hi,

              Thanks for the help. Apparantelly, i was using the sar archive inside the JBoss for a web application. In the manual is mentioned that if to use with a web application "Simply put the runtime libraries in the WEB-INF/lib folder of your web application archive (.war)." and everything worked fine after that.

              So the problem was because i was using the jbpm.sar archive with all the jar inside instead of putting them inside the WEB-INF/lib dir inside the war.


              Thanks joshua

              • 4. Re: ProcessClassLoader [ Urgent Help please !!!]
                rafaeldiaz923

                Hi i´m getting the same error when i try to use an object created by me as a process variable
                when i load (getVariable) the variable in the next node i get the exception

                How can i solve that problem????

                • 5. Re: ProcessClassLoader [ Urgent Help please !!!]
                  kukeltje

                  Rafael,

                  It's a standard j2ee classloading problem. When jbpm.jar is outside the war it can not access the classes inside the war. Simply because jBPM creates it's own process classloader to load versioned classes from the DB. There is a jira issue to (also?) use the context classloader, so jBPM can access classes in the war.

                  Solutions:
                  - as described above, put jbpm.jar in the war
                  - or pur the classes in the process archive
                  - wait for the issue to also use the context classloader to be solved

                  • 6. Re: ProcessClassLoader [ Urgent Help please !!!]
                    rafaeldiaz923

                    my war files is just a web service that call the process instance.
                    once the web service call the process instance
                    the proccess archive has the object that i want to put as a process instance
                    the exception is that:

                    11:13:07,608 INFO [STDOUT] OCURRIO UN ERROR..
                    11:13:07,608 INFO [STDOUT] org.jbpm.graph.def.DelegationException
                    11:13:07,623 INFO [STDOUT] at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:352)
                    11:13:07,623 INFO [STDOUT] at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:346)
                    11:13:07,623 INFO [STDOUT] at org.jbpm.graph.def.Node.execute(Node.java:333)
                    11:13:07,623 INFO [STDOUT] at org.jbpm.graph.def.Node.enter(Node.java:316)
                    11:13:07,639 INFO [STDOUT] at org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated>)
                    11:13:07,639 INFO [STDOUT] at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
                    11:13:07,639 INFO [STDOUT] at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:136)
                    11:13:07,655 INFO [STDOUT] at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$da47265b.enter(<generated>)
                    11:13:07,655 INFO [STDOUT] at org.jbpm.graph.def.Transition.take(Transition.java:119)
                    11:13:07,655 INFO [STDOUT] at org.jbpm.graph.def.Node.leave(Node.java:383)
                    11:13:07,655 INFO [STDOUT] at org.jbpm.graph.node.StartState.leave(StartState.java:70)
                    11:13:07,670 INFO [STDOUT] at org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated>)
                    11:13:07,670 INFO [STDOUT] at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
                    11:13:07,670 INFO [STDOUT] at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:136)
                    11:13:07,670 INFO [STDOUT] at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$da47265b.leave(<generated>)
                    11:13:07,686 INFO [STDOUT] at org.jbpm.graph.exe.Token.signal(Token.java:174)
                    11:13:07,686 INFO [STDOUT] at org.jbpm.graph.exe.Token.signal(Token.java:123)
                    11:13:07,686 INFO [STDOUT] at com.sinflash.ws.SinflashPublisherImpl.startPublishProcess(SinflashPublisherImpl.java:33)
                    11:13:07,686 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    11:13:07,702 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    11:13:07,702 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    11:13:07,702 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
                    11:13:07,717 INFO [STDOUT] at org.jboss.webservice.server.InvokerProviderJSE.invokeServiceEndpoint(InvokerProviderJSE.java:154)
                    11:13:07,717 INFO [STDOUT] at org.jboss.webservice.server.InvokerProvider.invokeMethod(InvokerProvider.java:305)
                    11:13:07,717 INFO [STDOUT] at org.jboss.axis.providers.java.RPCProvider.invokeTarget(RPCProvider.java:176)
                    11:13:07,717 INFO [STDOUT] at org.jboss.webservice.server.InvokerProviderJSE.invokeTarget(InvokerProviderJSE.java:93)
                    11:13:07,733 INFO [STDOUT] at org.jboss.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:121)
                    11:13:07,733 INFO [STDOUT] at org.jboss.axis.providers.java.JavaProvider.invoke(JavaProvider.java:358)
                    11:13:07,733 INFO [STDOUT] at org.jboss.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:73)
                    11:13:07,748 INFO [STDOUT] at org.jboss.axis.SimpleChain.doVisiting(SimpleChain.java:160)
                    11:13:07,748 INFO [STDOUT] at org.jboss.axis.SimpleChain.invoke(SimpleChain.java:123)
                    11:13:07,748 INFO [STDOUT] at org.jboss.axis.handlers.soap.SOAPService.invoke(SOAPService.java:560)
                    11:13:07,748 INFO [STDOUT] at org.jboss.webservice.server.ServerEngine.invokeInternal(ServerEngine.java:200)
                    11:13:07,764 INFO [STDOUT] at org.jboss.webservice.server.ServerEngine.invoke(ServerEngine.java:89)
                    11:13:07,764 INFO [STDOUT] at org.jboss.axis.transport.http.AxisServlet.doPost(AxisServlet.java:911)
                    11:13:07,764 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                    11:13:07,764 INFO [STDOUT] at org.jboss.axis.transport.http.AxisServletBase.service(AxisServletBase.java:370)
                    11:13:07,780 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                    11:13:07,780 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                    11:13:07,780 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    11:13:07,795 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
                    11:13:07,795 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                    11:13:07,795 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    11:13:07,795 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                    11:13:07,811 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                    11:13:07,811 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
                    11:13:07,811 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
                    11:13:07,827 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
                    11:13:07,827 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                    11:13:07,827 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                    11:13:07,827 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                    11:13:07,842 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                    11:13:07,842 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
                    11:13:07,842 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
                    11:13:07,842 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                    11:13:07,858 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                    11:13:07,858 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
                    11:13:07,858 INFO [STDOUT] Caused by: org.jbpm.graph.def.DelegationException
                    11:13:07,873 INFO [STDOUT] at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:352)
                    11:13:07,873 INFO [STDOUT] at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:346)
                    11:13:07,873 INFO [STDOUT] at org.jbpm.graph.def.Node.execute(Node.java:333)
                    11:13:07,873 INFO [STDOUT] at org.jbpm.graph.def.Node.enter(Node.java:316)
                    11:13:07,889 INFO [STDOUT] at org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated>)
                    11:13:07,889 INFO [STDOUT] at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
                    11:13:07,889 INFO [STDOUT] at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:136)
                    11:13:07,889 INFO [STDOUT] at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$da47265b.enter(<generated>)
                    11:13:07,905 INFO [STDOUT] at org.jbpm.graph.def.Transition.take(Transition.java:119)
                    11:13:07,905 INFO [STDOUT] at org.jbpm.graph.def.Node.leave(Node.java:383)
                    11:13:07,905 INFO [STDOUT] at org.jbpm.graph.def.Node.leave(Node.java:347)
                    11:13:07,905 INFO [STDOUT] at org.jbpm.graph.exe.ExecutionContext.leaveNode(ExecutionContext.java:120)
                    11:13:07,920 INFO [STDOUT] at com.sinflash.handlers.events.ExtractEventHandler.execute(ExtractEventHandler.java:84)
                    11:13:07,920 INFO [STDOUT] at org.jbpm.graph.def.Action.execute(Action.java:123)
                    11:13:07,920 INFO [STDOUT] at org.jbpm.graph.def.Action$$FastClassByCGLIB$$7876e90e.invoke(<generated>)
                    11:13:07,936 INFO [STDOUT] at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
                    11:13:07,936 INFO [STDOUT] at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:136)
                    11:13:07,936 INFO [STDOUT] at org.jbpm.graph.def.Action$$EnhancerByCGLIB$$da292a8f.execute(<generated>)
                    11:13:07,936 INFO [STDOUT] at org.jbpm.graph.def.Node.execute(Node.java:328)
                    11:13:07,952 INFO [STDOUT] ... 54 more
                    11:13:07,952 INFO [STDOUT] Caused by: java.lang.ClassCastException: com.sinflash.cm.ContentPackage
                    11:13:07,952 INFO [STDOUT] at com.sinflash.handlers.events.TransformEventHandler.execute(TransformEventHandler.java:17)
                    11:13:07,967 INFO [STDOUT] at org.jbpm.graph.def.Action.execute(Action.java:123)
                    11:13:07,967 INFO [STDOUT] at org.jbpm.graph.def.Action$$FastClassByCGLIB$$7876e90e.invoke(<generated>)
                    11:13:07,967 INFO [STDOUT] at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
                    11:13:07,967 INFO [STDOUT] at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:136)
                    11:13:07,983 INFO [STDOUT] at org.jbpm.graph.def.Action$$EnhancerByCGLIB$$da292a8f.execute(<generated>)
                    11:13:07,983 INFO [STDOUT] at org.jbpm.graph.def.Node.execute(Node.java:328)
                    11:13:07,983 INFO [STDOUT] ... 70 more
                    


                    • 7. Re: ProcessClassLoader [ Urgent Help please !!!]
                      rafaeldiaz923

                      My object has to be serializable in order to set it as a variable, and the document field is not serializable... could it be the problem???

                      • 8. Re: ProcessClassLoader [ Urgent Help please !!!]
                        aguizar

                        Nope, the exception is thrown in your code:

                        Caused by: java.lang.ClassCastException: com.sinflash.cm.ContentPackage
                        11:13:07,952 INFO [STDOUT] at com.sinflash.handlers.events.TransformEventHandler.execute(Transf
                        ormEventHandler.java:17)

                        What are you trying to do in your TransformEventHandler?

                        • 9. Re: ProcessClassLoader [ Urgent Help please !!!]
                          aguizar