3 Replies Latest reply on Apr 5, 2006 10:03 AM by gavin.king

    BPM Variable Injection

    go_rags

      I have put together a sample BPM demo using seam. I am having some trouble with accessing the variables. I have 2 BPM flows both use the same action handler.

      Flow 1 : start -> assign to actor -> call event (actionhandler) -> end
      Flow 2 : start -> call event (action handler) -> assign to actor -> end

      I inject 2 process context variables at the time of the process creation.

      In the first case my stuff is working fine. But in the second case I am not able to access the variables I injected, when I retrive them in the action handler I am getting a NULL value.

      Flow 1 :
      ~~~~~


      <process-definition name="nbook">
      
       <start-state name="start">
       <transition to="review"/>
       </start-state>
      
       <task-node name="nreview">
       <task name="nreview">
       <assignment actor-id="#{userId}"/>
       </task>
       <transition to="done"/>
       </task-node>
      
       <task-node name="assigncell">
       <event type="node-enter">
       <action name="assigncell" class="com.rags.action.AssignCell"></action>
       </event>
       <transition to="done"></transition>
       </task-node>
      
       <end-state name="done"/>
      
      </process-definition>
      
      


      Flow 2 :
      ~~~~~

      <process-definition name="bbook">
      
       <start-state name="start">
       <transition to="assigncell"/>
       </start-state>
      
       <task-node name="assigncell">
       <event type="node-enter">
       <action name="assigncell" class="com.rags.action.AssignCell"></action>
       </event>
       <transition to="breview"></transition>
       </task-node>
      
      
       <task-node name="breview">
       <task name="breview">
       <assignment actor-id="#{user.username}"/>
       </task>
       <transition to="done"/>
       </task-node>
      
       <end-state name="done"/>
      
      </process-definition>
      
      

      Action Handler :
      ~~~~~~~~~~~
      package com.rags.action;
      
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      
      public class AssignCell implements ActionHandler {
      
       public void execute(ExecutionContext bpmContext) throws Exception {
      
      
      
       String bookName = (String)bpmContext.getVariable("bookName");
      
       String bookStatus = (String)bpmContext.getVariable("bookStatus");
      
       int cell = Math.abs(bookName.hashCode() % 35);
       char block = (char)(Math.abs(bookName.hashCode() % 26) + 65);
      
       bookStatus = "Assigned to Block : " + block + " Cell : " + cell;
      
       bpmContext.setVariable("bookStatus", bookStatus);
      
       }
      
      }
      
      


      Can somebody tell me where I am going wrong?

      Thanks,
      Raghu.




        • 1. Re: BPM Variable Injection
          gavin.king

          Why not use a Seam component instead of a jBPM ActionHandler, and use @Out(scope=BUSINESS_PROCESS)?

          • 2. Re: BPM Variable Injection
            go_rags

            Gavin,

            The intent is to prove that a jBPM (action or a webservice call) can also be performed as part of the demo. So I have to use the ActionHandler and a Webservice to complete the demo.


            At the risk of sidetracking the issue, I faced a problem while i replaced the action handler with a seam component and I got an exception. Obviously I am doing something wrong because the numberguess example works fine. Can you plese let me know what is the problem in my code.

            SEAM component

            package com.sirs.action;
            
            import org.jboss.seam.ScopeType;
            import org.jboss.seam.annotations.In;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.annotations.Out;
            import org.jboss.seam.annotations.Scope;
            
            @Name("assignCell")
            @Scope(ScopeType.SESSION)
            public class AssignCell {
            
             @In
             String bookName;
            
             @In @Out(scope=ScopeType.BUSINESS_PROCESS)
             String bookStatus;
            
            
             public void doAssignment() {
            
             System.out.println("Excecuting AssignCell action handler!!");
            
             int cell = Math.abs(bookName.hashCode() % 35);
             char block = (char)(Math.abs(bookName.hashCode() % 26) + 65);
            
             bookStatus = "Assigned to Block : " + block + " Cell : " + cell;
            
             }
            
            }
            


            jPDL
            <process-definition name="bbook">
            
             <start-state name="start">
             <transition to="assigncell"/>
             </start-state>
            
             <task-node name="assigncell">
             <transition to="breview">
             <action expression="#{assignCell.doAssignment}" />
             </transition>
             </task-node>
            
             <task-node name="breview">
             <task name="breview">
             <assignment actor-id="#{user.username}"/>
             </task>
             <transition to="done"/>
             </task-node>
            
             <end-state name="done"/>
            
            </process-definition>
            


            The Exception I am getting
            
            09:34:33,203 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
            javax.faces.FacesException: Error calling action method of component with id _id0:_id8
             at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
             at javax.faces.component.UICommand.broadcast(UICommand.java:106)
             at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
             at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
             at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
             at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
             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:96)
             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:54)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
             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:868)
             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
             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: javax.faces.el.EvaluationException: Exception while invoking expression #{bookingbean.saveBooking}
             at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
             at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
             ... 25 more
            Caused by: javax.ejb.EJBException: org.jbpm.graph.def.DelegationException
             at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
             at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
             at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:190)
             at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
             at $Proxy262.saveBooking(Unknown Source)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
             ... 26 more
            Caused by: org.jbpm.graph.def.DelegationException
             at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:349)
             at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:343)
             at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:248)
             at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:212)
             at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:182)
             at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:166)
             at org.jbpm.graph.def.Transition.take(Transition.java:106)
             at org.jbpm.graph.def.Node.leave(Node.java:382)
             at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:198)
             at org.jbpm.graph.def.Node.leave(Node.java:346)
             at org.jbpm.graph.node.TaskNode.execute(TaskNode.java:188)
             at org.jbpm.graph.def.Node.enter(Node.java:316)
             at org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated>)
             at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
             at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
             at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$9159ed05.enter(<generated>)
             at org.jbpm.graph.def.Transition.take(Transition.java:119)
             at org.jbpm.graph.def.Node.leave(Node.java:382)
             at org.jbpm.graph.node.StartState.leave(StartState.java:70)
             at org.jbpm.graph.node.StartState$$FastClassByCGLIB$$4ed4ed8c.invoke(<generated>)
             at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
             at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
             at org.jbpm.graph.node.StartState$$EnhancerByCGLIB$$d8598a37.leave(<generated>)
             at org.jbpm.graph.exe.Token.signal(Token.java:174)
             at org.jbpm.graph.exe.Token.signal(Token.java:123)
             at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:217)
             at org.jboss.seam.interceptors.BusinessProcessInterceptor.createProcess(BusinessProcessInterceptor.java:136)
             at org.jboss.seam.interceptors.BusinessProcessInterceptor.afterInvocation(BusinessProcessInterceptor.java:105)
             at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:58)
             at sun.reflect.GeneratedMethodAccessor292.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
             at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
             at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:38)
             at sun.reflect.GeneratedMethodAccessor291.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
             at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
             at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:41)
             at org.jboss.seam.interceptors.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:51)
             at org.jboss.seam.interceptors.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:39)
             at com.sirs.demo.control.ProcessStarter$$EnhancerByCGLIB$$84238875.startBurlingtonApprovalProcess(<generated>)
             at com.sirs.demo.data.BookingBean.saveBooking(BookingBean.java:102)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
             at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:168)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
             at org.jboss.seam.interceptors.ValidationInterceptor.validateTargetComponent(ValidationInterceptor.java:65)
             at sun.reflect.GeneratedMethodAccessor297.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
             at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
             at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
             at sun.reflect.GeneratedMethodAccessor296.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
             at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
             at org.jboss.seam.interceptors.RollbackInterceptor.rollbackIfNecessary(RollbackInterceptor.java:30)
             at sun.reflect.GeneratedMethodAccessor295.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
             at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
             at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:32)
             at sun.reflect.GeneratedMethodAccessor294.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
             at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
             at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:58)
             at sun.reflect.GeneratedMethodAccessor293.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
             at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
             at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:58)
             at sun.reflect.GeneratedMethodAccessor292.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
             at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
             at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:38)
             at sun.reflect.GeneratedMethodAccessor291.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
             at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
             at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
             at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:41)
             at sun.reflect.GeneratedMethodAccessor290.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:120)
             at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:62)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
             ... 46 more
            Caused by: org.jbpm.JbpmException: couldn't evaluate expression '#{assignCell.doAssignment}'
             at org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator.evaluate(JbpmExpressionEvaluator.java:37)
             at org.jbpm.graph.def.Action.execute(Action.java:119)
             at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235)
             ... 158 more
            Caused by: org.jbpm.jpdl.el.ELException: An error occurred while invoking method "doAssignment" on an instance of class com.sirs.action.AssignCell$$En
            hancerByCGLIB$$a98a7a22
             at org.jbpm.jpdl.el.impl.Logger.logError(Logger.java:485)
             at org.jbpm.jpdl.el.impl.Logger.logError(Logger.java:589)
             at org.jbpm.jpdl.el.impl.ArraySuffix.evaluate(ArraySuffix.java:290)
             at org.jbpm.jpdl.el.impl.ComplexValue.evaluate(ComplexValue.java:146)
             at org.jbpm.jpdl.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:264)
             at org.jbpm.jpdl.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:191)
             at org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator.evaluate(JbpmExpressionEvaluator.java:34)
             ... 160 more
            
            



            Thanks,
            Raghu.

            • 3. Re: BPM Variable Injection
              gavin.king

              Dunno, the stack trace is not showing the underlying exception. Use your debugger to find the deepest exception.