9 Replies Latest reply on Jul 25, 2009 3:49 PM by holla2040

    jBPM 4.0 instance creation results in single task

      FYI, I've poked around for about 6 hours looking for an answer before posting.

      ----

      I'm evaluating 4.0 for a handheld project where a user's current task list is downloaded for the day (ie. all their tasks are viewable). I've modified Jeff Yu's jpbm-helloworld process to include 5 tasks. It deploys and functions correctly, ie I can step through the tasks in the jbpm-console. The task tab only shows a single current task not the 5 from my process.

      I further investigated the API and found these TaskQuery methods.

      TaskQuery processDefinitionId(java.lang.String processDefinitionId) - only select tasks that are associated to the given process definition

      TaskQuery processInstanceId(java.lang.String processInstanceId) - only select tasks that are associated to the given process instance

      TaskService TaskQuery.list() execution returns a single task (the current task) for both TaskQuery configurations.

      So I opened the jbpm database and saw that a single row exists in JBPM_TASK table (the current task). So it appears that startProcessInstance doesn't create all process tasks, the engine only creates one at a time.

      So my question is, can I start process instances where all tasks are created (ie inserted into JBPM_TASK table)?

      If not, can this be done in jBPM 3.x?

      Thanks for your time,
      Craig

        • 1. Re: jBPM 4.0 instance creation results in single task
          kukeltje

          Please show us your processdefinition.

          • 2. Re: jBPM 4.0 instance creation results in single task

            Thanks for replying. Here's my quick jBPM HW hack.

            <?xml version="1.0" encoding="UTF-8"?>
            
            <process name="helloworld" xmlns="http://jbpm.org/4.0/jpdl">
             <start g="78,13,48,48" name="start">
             <transition g="-90,-4" name="to request" to="request"/>
             </start>
             <end g="457,369,48,48" name="end"/>
             <java class="org.jbpm.helloworld.Println" g="174,95,92,52" method="request" name="request">
             <transition g="-85,-6" name="to review" to="review"/>
             </java>
             <task assignee="alex" g="277,235,92,52" name="review" form="review.ftl">
             <transition g="-73,-25" name="approved" to="review1"/>
             </task>
             <task assignee="alex" g="277,235,92,52" name="review1">
             <transition g="-73,-25" name="approved1" to="review2"/>
             </task>
             <task assignee="alex" g="277,235,92,52" name="review2">
             <transition g="-73,-25" name="approved2" to="audit"/>
             </task>
             <state g="498,134,92,52" name="audit">
             <transition g="-54,-19" name="to end" to="end"/>
             </state>
            </process>
            


            • 3. Re: jBPM 4.0 instance creation results in single task
              shekharv

              The task is created when the execution reaches that stage in the processDefinition.

              eg:

               <task assignee="alex" g="277,235,92,52" name="review1">
               <transition g="-73,-25" name="approved1" to="review2"/>
               </task>
               <task assignee="alex" g="277,235,92,52" name="review2">
               <transition g="-73,-25" name="approved2" to="audit"/>
               </task>
              


              'review2' will not be created until 'review1' is completed.

              Consider this:

               <task assignee="alex" g="277,235,92,52" name="review0">
               <transition g="-73,-25" name="approved1" to="review1"/>
               <transition g="-73,-25" name="approved2" to="review2"/>
               </task>
               <task assignee="alex" g="277,235,92,52" name="review1">
               <transition g="-73,-25" name="approved" to="review2"/>
               </task>
               <task assignee="alex" g="277,235,92,52" name="review2">
               <transition g="-73,-25" name="approved2" to="audit"/>
               </task>
              


              You have two options in tasknode review1: unless you pick one of them while completing the task, the next task cannot be determined, so the next task will not be created up front.

              • 4. Re: jBPM 4.0 instance creation results in single task

                shekhar,

                I agree, that's what I determined and now understand why from your example.

                Here's a couple more questions, if you don't mind

                Is the 'task creation when necessary' approach common with all BPM engines?

                Does jBPM 3.x have the same approach?

                Thanks for your time.
                Craig

                • 5. Re: jBPM 4.0 instance creation results in single task
                  kukeltje

                  The moment tasks are created depend on where they are in a flow like Shekar showed.

                  You can also make a fork/join with all tasks paralllel.

                  And yes, all 'bpm engines' do it this way (including jBPM 3)

                  • 6. Re: jBPM 4.0 instance creation results in single task

                    kukeltje,

                    Thanks for your answer. Parallel tasks is not something I would have figured out, makes sense though (I'm a process newbie).

                    I've been working the fork/join approach for a couple hours but am now struggling with runtime errors.

                    <process name="helloworld" xmlns="http://jbpm.org/4.0/jpdl">
                     <start name="start1" g="166,38,48,48">
                     <transition name="to fork1" to="fork1" g="-44,-18"/>
                     </start>
                     <fork name="fork1" g="192,117,48,48">
                     <transition name="to task1" to="task1" g="-45,-18"/>
                     <transition name="to task2" to="task2" g="-45,-18"/>
                     <transition name="to task3" to="task3" g="-45,-18"/>
                     </fork>
                     <task assignee="alex" name="task1" g="80,233,92,52">
                     <transition name="to join1" to="join1" g="-42,-18"/>
                     </task>
                     <task assignee="alex" name="task2" g="219,248,92,52">
                     <transition name="to join1" to="join1" g="-42,-18"/>
                     </task>
                     <task assignee="alex" name="task3" g="325,242,92,52">
                     <transition name="to join1" to="join1" g="-42,-18"/>
                     </task>
                     <join name="join1" g="217,330,48,48">
                     <transition name="to end1" to="end1" g="-42,-18"/>
                     </join>
                     <end name="end1" g="191,406,48,48"/>
                    </process>
                    


                    While I start my helloworld process instance, I get a GWT console error and jboss console errors. See below if interested. Let me poke around some more to try to figure out what's going on.

                    I'm running
                    jPBM4.0
                    jboss-5.0.1.GA
                    hsqldb

                    Thanks,
                    Craig



                     * URL: 'http://localhost:8080/gwt-console-server/rs/process/definition/helloworld-17/new_instance'
                     * Action: 'org.jboss.bpm.console.client.process.StartNewInstanceAction'
                     * Exception: 'class com.google.gwt.http.client.RequestException'
                    HTTP 500: Unknown error
                    



                    16:42:43,301 ERROR [STDERR] 46007 [http-127.0.0.1-8080-5] ERROR org.jboss.resteasy.core.SynchronousDispatcher - failed to execute
                    16:42:43,301 ERROR [STDERR] javax.ws.rs.WebApplicationException: java.lang.RuntimeException: Unexpected invocation exception: null
                    16:42:43,301 ERROR [STDERR] at org.jboss.bpm.console.server.ProcessMgmtFacade.newInstance(ProcessMgmtFacade.java:194)
                    16:42:43,302 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    16:42:43,302 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                    16:42:43,302 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                    16:42:43,302 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:616)
                    16:42:43,302 ERROR [STDERR] at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:117)
                    16:42:43,302 ERROR [STDERR] at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:260)
                    16:42:43,302 ERROR [STDERR] at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:232)
                    16:42:43,302 ERROR [STDERR] at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:166)
                    16:42:43,302 ERROR [STDERR] at org.jboss.resteasy.core.DispatcherUtilities.getJaxrsResponse(DispatcherUtilities.java:142)
                    16:42:43,302 ERROR [STDERR] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)
                    16:42:43,302 ERROR [STDERR] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:173)
                    16:42:43,302 ERROR [STDERR] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:93)
                    16:42:43,303 ERROR [STDERR] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:68)
                    16:42:43,303 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                    16:42:43,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                    16:42:43,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    16:42:43,303 ERROR [STDERR] at org.jboss.bpm.console.server.util.GWTJsonFilter.doFilter(GWTJsonFilter.java:59)
                    16:42:43,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                    16:42:43,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    16:42:43,303 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                    16:42:43,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                    16:42:43,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    16:42:43,303 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                    16:42:43,303 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                    16:42:43,303 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                    16:42:43,304 ERROR [STDERR] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
                    16:42:43,304 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                    16:42:43,304 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                    16:42:43,304 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                    16:42:43,304 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                    16:42:43,304 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                    16:42:43,304 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                    16:42:43,304 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                    16:42:43,304 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                    16:42:43,304 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                    16:42:43,304 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
                    16:42:43,304 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                    16:42:43,304 ERROR [STDERR] at java.lang.Thread.run(Thread.java:636)
                    16:42:43,305 ERROR [STDERR] Caused by: java.lang.RuntimeException: Unexpected invocation exception: null
                    16:42:43,305 ERROR [STDERR] at org.jboss.bpm.console.server.util.InvocationProxy.invoke(InvocationProxy.java:80)
                    16:42:43,305 ERROR [STDERR] at $Proxy146.newInstance(Unknown Source)
                    16:42:43,305 ERROR [STDERR] at org.jboss.bpm.console.server.ProcessMgmtFacade.newInstance(ProcessMgmtFacade.java:189)
                    16:42:43,305 ERROR [STDERR] ... 38 more
                    16:42:43,305 ERROR [STDERR] Caused by: java.lang.reflect.InvocationTargetException
                    16:42:43,305 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    16:42:43,305 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                    16:42:43,305 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                    16:42:43,305 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:616)
                    16:42:43,305 ERROR [STDERR] at org.jboss.bpm.console.server.util.InvocationProxy.invoke(InvocationProxy.java:64)
                    16:42:43,306 ERROR [STDERR] ... 40 more
                    16:42:43,306 ERROR [STDERR] Caused by: java.lang.NullPointerException
                    16:42:43,306 ERROR [STDERR] at org.jbpm.integration.console.ModelAdaptor.execution2TokenReference(ModelAdaptor.java:101)
                    16:42:43,306 ERROR [STDERR] at org.jbpm.integration.console.ModelAdaptor.adoptExecution(ModelAdaptor.java:73)
                    16:42:43,306 ERROR [STDERR] at org.jbpm.integration.console.ProcessManagementImpl.newInstance(ProcessManagementImpl.java:250)
                    16:42:43,306 ERROR [STDERR] ... 45 more
                    
                    
                    




                    • 7. Re: jBPM 4.0 instance creation results in single task
                      kukeltje

                      new questions belong in new topics please

                      • 8. Re: jBPM 4.0 instance creation results in single task

                        OK. Let's close this thread. Thanks for your help.

                        • 9. Re: jBPM 4.0 instance creation results in single task

                          OK. Let's close this thread. Thanks for your help.