5 Replies Latest reply on Jan 18, 2010 5:47 PM by Andy Barreras

    How a pass signal from state a task or java?? I do not under

    carlos mauricio jaramillo henao Newbie

      Hi

      I want to pass the signal from one state to java, but I get the error:

      org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalArgumentException: id to load is required for loading
       org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:319)
       org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:230)
       org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:206)
       org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:360)
       org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:173)
       org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:93)
       org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:68)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       org.jboss.bpm.console.server.util.GWTJsonFilter.doFilter(GWTJsonFilter.java:59)
      


      Not covered, somebody could help me

      <state g="438,14,92,52" name="verify">
       <on event="start">
       <timer duedate="1 minutes" repeat="10 seconds"/>
       <event-listener class="com.configuracion.eventos.VerificarReposicion">
       <field name="documento"><object expr="#{resReposicion}"/></field>
       <field name="caf"><object expr="#{txtCaf}"/></field>
       </event-listener>
       </on>
       <transition g="-15,-19" to="hello"/>
       </state>
      
       <java class="com.configuracion.dao.ReposicionDao" g="571,14,107,54" method="helloWorld" name="hello">
       <transition to="end"/>
       </java>
      


      The NOTIFY method is as follows

      public void notify(EventListenerExecution executionListener) throws Exception {
       String respuesta = executionListener.getVariable("response")+"";
       if (processEngine == null) {
       processEngine = Configuration.getProcessEngine();
       executionService = processEngine.getExecutionService();
       }
       ProcessInstance processInstance = executionService.findProcessInstanceById(executionListener.getId());
       Execution execution = processInstance.findActiveExecutionIn("verify");
       System.out.println("===>"+execution.getId());
      if(executionListener.getVariable("response").toString().equals("N")){
       processInstance = executionService.signalExecutionById(execution.getId());
       }
       }


      Thanks

        • 1. Re: How a pass signal from state a task or java?? I do not u
          Santanu Saraswati Novice

          What are you trying to achieve here?

          Both your code and your jpdl look flawed.

          You seems to expect a variable "response" changing its value. But who is changing the value (means where is the code which changes the value of "response") and who is setting the value in execution context?

          Also, I get a feel that you are expecting start event triggered again and again without going out of the node. That is also not possible.

          If you can explain your requirement and let us know how response variable will be set and will be changed then we can try to correct your process flow.

          • 2. Re: How a pass signal from state a task or java?? I do not u
            carlos mauricio jaramillo henao Newbie

            Thanks for answering

            I want that when "response" comes in N get out of the event and pass the task, "hello". The variable "response" is filled with

            response = reposicion.verificarCarguePorReposicion(documento, caf); //RETURN N or S
            


            I this error when I go out the signal executionService.signalExecutionById (execution.getId ());

            When I remove executionService.signalExecutionById (execution.getId ()); I stay in an endless cycle that never goes to the next task

            public void notify(EventListenerExecution executionListener) throws Exception {
             String response = executionListener.getVariable("response")+"";
             if (response.equals(null)) {
             response = new String();
             executionListener.setVariable("response", response);
             }
             ReposicionDao reposicion = new ReposicionDao();
             response = reposicion.verificarCarguePorReposicion(documento, caf); //RETURN N or S
             if (processEngine == null) {
             processEngine = Configuration.getProcessEngine();
             executionService = processEngine.getExecutionService();
             }
             ProcessInstance processInstance = executionService.findProcessInstanceById(executionListener.getId
            ());
             Execution execution = processInstance.findActiveExecutionIn("verify");
             System.out.println("===>"+execution.getId());
            //WHEN response IS EQUAL TO N I MOVE TO ANOTHER TASK AND GET OUT OF THE TIMER
            if(executionListener.getVariable("response").toString().equals("N")){
             processInstance = executionService.signalExecutionById(execution.getId());
             }
             }
            


            I hope having explained

            • 3. Re: How a pass signal from state a task or java?? I do not u
              Santanu Saraswati Novice

              Carlos,

                 I think you should have some code to trigger the flow when the value of "response" changes.

               

                 What I mean here is, the following code of yours

              reposicion.verificarCarguePorReposicion(documento, caf)

                must be doing some db lookup, or something like that to check for the value of "response". So I assume there must some other code in the application which changes the value in the db. When you chenge that value then you should trigger the flow. In your flow keep a wait node which will wait for this signal and a decision node following the wait node. In the decision node have the code above and then decide whether to go back to the wait node or to move on to the next node.

               

                  I know a little code is more helpful than a paragraph of text, but I still have no idea where are you actually changing the value.

               

                  I would also suggest you to review your code once. I am sure you already are aware, but still to reaffirm:

               

                 String response = "N";

                 executionListener.setVariable("response", response);

               

                 response = reposition.varificarCarguePorReposicion(documento, caf);

                 //the following line will always return "N", no matter what the return value of varify...(...)

                 //method returns

                 executionListener.getVariable("response");


              • 4. Re: How a pass signal from state a task or java?? I do not under
                Andy Barreras Newbie

                I was having the same issue.  I believe that the reason was that I was calling a listener on the wrong state event:

                 

                   <state g="137,123,150,52" name="Generate Visibilities">
                        <on event="start">
                        <event-listener class="my.package.MyListener" />
                        </on>
                      <transition g="-143,-10" name="to Check Out Time Segment" to="Check Out Time Segment"/>
                      <transition name="to cancel" to="cancel" g="-48,-18"/>
                      <transition name="to error" to="error" g="-42,-18"/>
                   </state>

                 

                Within the listener, I was doing some external work then calling the executionService.signalExecutionById()method.  I think the reason it was failing was because I was calling this method within the state's start event.  In jBPM, you can't trigger a transition to another state until the (current) state execution stops.  When I changed the jpdl code to call the listener on the state's end event, the exception went away:

                 

                   <state g="137,123,150,52" name="Generate Visibilities">
                         <on event="end">
                         <event-listener class="
                my.package.MyListener" />
                         </on>
                       <transition g="-143,-10" name="to Check Out Time Segment" to="Check Out Time Segment"/>
                       <transition name="to cancel" to="cancel" g="-48,-18"/>
                       <transition name="to error" to="error" g="-42,-18"/>
                    </state>

                 

                Hope this helps.

                • 5. Re: How a pass signal from state a task or java?? I do not under
                  Andy Barreras Newbie
                  Actually, my last reply was not a fix.  The listenersimply  wasn't getting fired at all from the process definition's 'end' state event hence no exception.  I looked at other threads via google and other folks seemed to have similar issues (not with jBPM).  Accordiong to some, it seems to be associated with a bug in Hibernate.  I'm using jBPM 4.2 right now.  I will upgrade to 4.3 and see what happens.