9 Replies Latest reply on Apr 6, 2010 10:50 AM by ABIDI Sami

    Asynchronus execution error

    ABIDI Sami Apprentice

      Hello,

       

      I want to execute a jbpm process in asynchronous continuation mode, and here is a part of the source code that i used :

       

              ProcessEngine processengine = new Configuration().buildProcessEngine();
             
              RepositoryService repositoryservice = processengine.getRepositoryService();
             
              ExecutionService executionservice = processengine.getExecutionService();
             
              ManagementService managementService = processengine.getManagementService();
             
             
              
              ProcessInstance processInstance = executionservice.startProcessInstanceById("Clef-4");
             
             
              Job job = null;
             
              job = managementService.createJobQuery().processInstanceId(processInstance.getId()).uniqueResult();
             
             
              managementService.executeJob(job.getId());

       

       

       

      I would like from this code to execute only the first task of my process.

       

      As result, I have the first task executed, but I have also an error saying that jbpm couldn't load my class containing the task even if the task was executed.

       

      Here is the error message :

       

       

      15:06:33,684 FIN | [SQL]
          select
              jobimpl0_.DBID_ as DBID1_6_0_,
              jobimpl0_.DBVERSION_ as DBVERSION3_6_0_,
              jobimpl0_.DUEDATE_ as DUEDATE4_6_0_,
              jobimpl0_.STATE_ as STATE5_6_0_,
              jobimpl0_.ISEXCLUSIVE_ as ISEXCLUS6_6_0_,
              jobimpl0_.LOCKOWNER_ as LOCKOWNER7_6_0_,
              jobimpl0_.LOCKEXPTIME_ as LOCKEXPT8_6_0_,
              jobimpl0_.EXCEPTION_ as EXCEPTION9_6_0_,
              jobimpl0_.RETRIES_ as RETRIES10_6_0_,
              jobimpl0_.PROCESSINSTANCE_ as PROCESS11_6_0_,
              jobimpl0_.EXECUTION_ as EXECUTION12_6_0_,
              jobimpl0_.CFG_ as CFG13_6_0_,
              jobimpl0_.SIGNAL_ as SIGNAL14_6_0_,
              jobimpl0_.EVENT_ as EVENT15_6_0_,
              jobimpl0_.REPEAT_ as REPEAT16_6_0_,
              jobimpl0_.CLASS_ as CLASS2_6_0_
          from
              JBPM4_JOB jobimpl0_
          where
              jobimpl0_.DBID_=?
      15:06:33,684 FST | [LongType] binding '820002' to parameter: 1
      15:06:33,694 FST | [StringType] returning 'ExeAct' as column: CLASS2_6_0_
      15:06:33,694 FST | [IntegerType] returning '6' as column: DBVERSION3_6_0_
      15:06:33,694 FST | [TimestampType] returning null as column: DUEDATE4_6_0_
      15:06:33,694 FST | [StringType] returning 'error' as column: STATE5_6_0_
      15:06:33,694 FST | [BooleanType] returning 'false' as column: ISEXCLUS6_6_0_
      15:06:33,694 FST | [StringType] returning null as column: LOCKOWNER7_6_0_
      15:06:33,694 FST | [TimestampType] returning null as column: LOCKEXPT8_6_0_
      15:06:33,694 FST | [TextType] returning 'org.jbpm.pvm.internal.wire.JbpmClassNotFoundException: couldn't load class PE.Fonctions
          at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.construct(ObjectDescriptor.java:146)
          at org.jbpm.pvm.internal.wire.WireContext.construct(WireContext.java:469)
          at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:448)
          at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:258)
          at org.jbpm.pvm.internal.util.ReflectUtil.instantiateUserCode(ReflectUtil.java:310)
          at org.jbpm.pvm.internal.wire.usercode.UserCodeReference.getObject(UserCodeReference.java:63)
          at org.jbpm.pvm.internal.wire.usercode.UserCodeReference.getObject(UserCodeReference.java:47)
          at org.jbpm.jpdl.internal.activity.JavaActivity.perform(JavaActivity.java:57)
          at org.jbpm.jpdl.internal.activity.JpdlAutomaticActivity.execute(JpdlAutomaticActivity.java:15)
          at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60)
          at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:656)
          at org.jbpm.pvm.internal.model.op.ExecuteActivityMessage.execute(ExecuteActivityMessage.java:46)
          at org.jbpm.pvm.internal.cmd.ExecuteJobCmd.execute(ExecuteJobCmd.java:76)
          at org.jbpm.pvm.internal.cmd.ExecuteJobCmd.execute(ExecuteJobCmd.java:42)
          at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
          at org.jbpm.pvm.internal.tx.JtaTransactionInterceptor.executeInNewTx(JtaTransactionInterceptor.java:87)
          at org.jbpm.pvm.internal.tx.JtaTransactionInterceptor.execute(JtaTransactionInterceptor.java:66)
          at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
          at org.jbpm.pvm.internal.tx.JtaRetryInterceptor.executeWithRetry(JtaRetryInterceptor.java:52)
          at org.jbpm.pvm.internal.tx.JtaRetryInterceptor.execute(JtaRetryInterceptor.java:45)
          at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
          at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
          at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
          at org.jbpm.pvm.internal.jobexecutor.JobParcel.run(JobParcel.java:48)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
          at java.util.concurrent.FutureTask.run(FutureTask.java:123)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
          at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.ClassNotFoundException: class 'PE.Fonctions' could not be found in deployment 540001
          at org.jbpm.pvm.internal.repository.DeploymentClassLoader.findClass(DeploymentClassLoader.java:119)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Class.java:242)
          at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.construct(ObjectDescriptor.java:144)
          ... 29 more
      ' as column: EXCEPTION9_6_0_

       

       

       

      Do someone have ideas about how to solve this problem?

      Thanks!

        • 1. Re: Asynchronus execution error
          Maciej Swiderski Master

          More information would be helpful, such as your process definition.

           

          On a first look it seems like your deployment is not complete. Perhaps (and this is just a rough guess) after your task you have a java activity that requires that class but the class was not part of deployment (resources of type .class was not added before calling deploy method)

          • 2. Re: Asynchronus execution error
            ABIDI Sami Apprentice

            This is my process :

             

            <?xml version="1.0" encoding="UTF-8"?>

             

            <process key="Clef" name="FirstPEProcess" xmlns="http://jbpm.org/4.3/jpdl">

             

               <start g="21,98,48,48">
                  <transition to="ConfigurerRepId"/>
              </start>

             

               <java g="140,95,101,52" continue="async" method="ConfigurerRepId" name="ConfigurerRepId">
                  <transition to="EnregistrerSAPP"/>
              </java>
             
              <java g="315,99,106,52" continue="async" method="EnregistrerSAPP" name="EnregistrerSAPP">
                  <transition to="makeSignatureFile"/>
              </java>
             
              <java g="533,99,133,52" continue="async" method="makeSignatureFile" name="makeSignatureFile">
                  <transition to="CallForArchive"/>
               </java>
              
               <java g="736,102,92,52" continue="async" method="scenarioComplet2" name="CallForArchive">
                  <transition to="end"/>
               </java>
              
               <end g="892,103,48,48" name="end"/>
              
            </process>

             

            I think that your idea is very logical, but I don't know how to add the class ass a part of the deployment? could you help me please?!

            • 3. Re: Asynchronus execution error
              HuiSheng Xu Master

              Hi ABIDI,

                The easy way to deploy all classes and xml is using the zip, you can put all classes and xml files into a zip file, and deploy it together.

               

                processEngine.createDeployment().addResourcesFromZipInputStream(zis).deploy;

               

                When you do that, please make sure putting the class file on the right place, you could see more information in the User Guide.

               

              http://docs.jboss.com/jbpm/v4/userguide/html_single/#deployingclasses

              • 4. Re: Asynchronus execution error
                ABIDI Sami Apprentice

                Hi Huisheng,

                 

                Thank you for this explanation, but deploying a zip archive containing classes didn't add any deployment in jbpm database, and no process was deployed. So I am not sure that I did this deployment correctly : I took all the packages of class files containing th process and all classes and i executed the zip deployment code, but that didn't add any deployment to the jbpm database. Is that the correct way you meant??

                 

                I would like to know also if the deployment with ant can deploy classes, I tried that but I don't know if my ant file is good or not, because program couldn't load the class either.

                 

                My ant file is the same as the examples of jbpm installation one, but I added these elements :

                 

                <path id="jbpm.libs.incl.dependencies">
                      <pathelement location="${jbpm.home}/eclipse/workspace/PETest1/target/classes" />
                      <fileset dir="${jbpm.home}">
                        <include name="jbpm.jar" />
                      </fileset>
                      <fileset dir="${jbpm.home}/lib" />
                    </path>
                   
                    <jar destfile="${jbpm.home}/eclipse/workspace/PETest1/target/PETest1.bar">
                      <fileset dir="${jbpm.home}/eclipse/workspace/PETest1/src">
                        <include name="**/*.jpdl.xml" />
                       
                      </fileset>
                    </jar>
                   
                    <taskdef name="jbpm-deploy"
                        classname="org.jbpm.pvm.internal.ant.JbpmDeployTask"
                        classpathref="jbpm.libs.incl.dependencies" />
                   
                    <jbpm-deploy file="${jbpm.home}/eclipse/workspace/PETest1/target/PETest1.bar" />

                 

                also I replaced all the directories by the new ones.

                Is that correct? ... What should be the problem according to you??

                 

                Thanks

                • 5. Re: Asynchronus execution error
                  Maciej Swiderski Master

                  Hi,

                   

                  yes, ant script is good way of doing deployments.

                   

                  Based on what I can see in your ant script it misses resources to be included in the jar archive. At the moment you only include jpdl.xml files regardless of package location. You should include your classes exactly the same way.

                   

                  Here is how it should look like. In addition, please include any other resources as well (such as task form .ftl, rules definition .rtl)

                      <jar  destfile="${jbpm.home}/eclipse/workspace/PETest1/target/PETest1.bar">
                         <fileset dir="${jbpm.home}/eclipse/workspace/PETest1/src">
                           <include name="**/*.jpdl.xml" />        
                           <include name="**/*.class" />
                         </fileset>
                      </jar>
                  

                   

                  HTH

                  Maciej

                  • 6. How to execute a process with multiple break points
                    ABIDI Sami Apprentice

                    Hi,

                     

                    Finally I could deploy my classes, thanks to you!

                     

                    But my problem now is that I don't know how to make my process stop after each transition (at each java element for example). I want that it waits for a continuation command, then it continues. For example, that can be a swing frame in which I have a button that launches the next step of the process.

                     

                    Here in attachement you can find my 3 projects :

                     

                    AsyncDeployment : deployment of an asynchronous little process with necessary classes.

                    AsyncDeploymentCustom : deployment of an asynchronous process with custom element.

                     

                    AsyncTest1 : Here is the main class that I used to execute my different processes.

                     

                    Can someone help me to make a little asynchronous process that allows me to execute it step by step?

                    Can I provide data during execution?

                     

                    Thank you!

                    • 7. Re: How to execute a process with multiple break points
                      HuiSheng Xu Master

                      Hi ABIDI,

                        If you want do execute a ProcessInstance step by step, you should use Automatic activity like java or script. You should use state or task activity do do this. The state and task activity will stop the execution and wait a signal, until we invoke the executionService.signalExecutionById() the execution won't continue to next activity.

                       

                        If you want to provide some data into processInstance, you could use signalExecutionById(String signalName, Map variables) to do that. Or you could invoke executionService.setVariable(exeuctionId, name, value) directly.

                       

                      cheers.

                      • 8. Re: How to execute a process with multiple break points
                        ABIDI Sami Apprentice

                        Did you rather mean "I shouldn't use automatic activity" ?

                         

                        I tried already to use custom element but I didn't succeed to make it go to the next step. I used this code :

                         

                        Execution execution = processInstance.findActiveExecutionIn("wait");
                        executionService.signalExecutionById(execution.getId());

                         

                        but when I execute that, i have NullpointerException, it is the execution object that is null. Do you have an idea about what makes the problem?

                         

                        As you described it here, I can't execute an swing Frame to make process continue. Is that true??

                        • 9. Re: How to execute a process with multiple break points
                          ABIDI Sami Apprentice

                          That's OK Huisheng,

                           

                          Finally I used a custom element to do that, now I can execute my process step by step.

                           

                          Thank you very much.