10 Replies Latest reply on Oct 17, 2006 11:48 AM by Ansgar Thobe

    Problem execute actions on jboss

    Ansgar Thobe Newbie

      Hello!
      I have some problems with exectue Actions on a jboss server. I ve made a little test definition with a start-state, a state and an end-state. The state should execute an action. In junit, the workflow runs without any problem. But when i deploy it on a jboss, jbpm doesn t execute the action. When i ask the processinstance for its node name, i can see, that the workflow runs form one state to another. But without executing the action. I ve tried serveral kinds of action ( befor-signal, after-signal...) but without any change. Can someone tell me, what i ve made wrong? ( once again a stupid error i ve produced?? )
      I use jbpm 3.1.1. and the jboss 4.0.3.sp1
      my processdefinition

      <?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="processActivity">
       <start-state name="start">
       <transition name="startWorkflow" to="createActivity">
       </transition>
       </start-state>
       <state name="createActivity">
       <transition name="created" to="end1"></transition>
       <event type="after-signal">
       <action name="action1" class="de.uniSiegen.crm.server.workflow.action.TestActivity"></action>
       </event>
       </state>
       <end-state name="end1"></end-state>
      </process-definition>


      my simple action handler:
      package de.uniSiegen.crm.server.workflow.action;
      
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      
      public class TestActivity implements ActionHandler {
      
       public void execute(ExecutionContext arg0) throws Exception {
      
       System.out.println(" in the test activity!!!!!");
       }
      
      }


      I would be very grateful for any help!

        • 1. Re: Problem execute actions on jboss
          Ansgar Thobe Newbie

          One appendix:
          I forgot to mention, that there is no error or anything produced from jboss.

          • 2. Re: Problem execute actions on jboss
            Frédéric Ferrant Newbie

            are you sure System.out.println(...); prints something using jBoss server?

            • 3. Re: Problem execute actions on jboss
              Ansgar Thobe Newbie

              I have also tried an log4j info output. but there is also nothing to see on jboss ( the log4j is ok, i can see other info outputs...)

              • 4. Re: Problem execute actions on jboss
                Ansgar Thobe Newbie

                Makes it a differenz, wether the workflow runs i a web application or in a backend?
                If i put my workflow in the war archiv of my web application, i can execute it without any problem. If i try it in the backend ( jar archiv ), the workflow runs without execute the actions.
                Is there any reason, why jbpm should run in the backend?

                • 5. Re: Problem execute actions on jboss
                  Ansgar Thobe Newbie

                  In the meantime, i could isolate the problem a little bit.
                  If i create a processinstance direct on the parsed processdefinition, jbpm executes the action.


                  step 1:

                  try{
                  
                   JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("jbpm.cfg.xml");
                  
                  
                   JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
                   GraphSession graphSession = jbpmContext.getGraphSession();
                  
                   ProcessDefinition processDefinition =ProcessDefinition.parseXmlResource("activityWorkflow.par/processdefinition.xml");
                  
                   ProcessInstance processInstance = processDefinition.createProcessInstance();
                  
                   processInstance.signal("startWorkflow");
                   processInstance.signal("created");
                  
                   jbpmContext.save(processInstance);
                  
                   }catch(Exception e){
                   e.printStackTrace();
                   }finally{
                   jbpmContext.close();
                   }
                   }



                  If i first save the processInstance and later load it back from the database, the action won't execute.



                  JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("jbpm.cfg.xml");
                  
                  JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
                  
                   try{
                   GraphSession graphSession = jbpmContext.getGraphSession();
                  
                   ProcessDefinition processDefinition =ProcessDefinition.parseXmlResource("activityWorkflow.par/processdefinition.xml");
                  
                   ProcessInstance processInstance = processDefinition.
                   Long id = Long.valueOf(processInstance.getId());
                  
                   jbpmContext.deployProcessDefinition(processDefinition);
                   jbpmContext.save(processInstance);
                   }catch(Exception e){
                   e.printStackTrace;
                   }finally{
                   jbpmContext.close();
                   }
                  return id;


                  step 2:

                  JbpmConfiguration jbmpConfiguration = JbpmConfiguration.getInstance("jbpm.cfg.xml");
                  JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
                  try{
                   GraphSession graphSession = jbpmContext.getGraphSession();
                  
                   ProcessInstance processInstance = graphSession.loadProcessInstance(processId.longValue());
                  
                   processInstance.signal();
                   jbpmContext.save(processInstance);
                   }catch(Exception e){
                   e.printStackTrace;
                   }finally{
                   jbpmContext.close();
                  }


                  Is there something wrong in the way i save and load the processInstance?

                  • 6. Re: Problem execute actions on jboss
                    Ansgar Thobe Newbie

                    Hello!
                    During the debuging i can see, that of the values of the processInstance, which i loaded from the graphSession are null.
                    For example the processDefinition of the processInstance is null.
                    In the database, the ProcessDefinition for the ProcessInstance is correctly set.
                    So i guess, it is maybe a problem with hibernate.
                    Has someone an idee, what i can do?
                    It seems, that i am the only one, who has this problem so i guess, it is a really stupid error, i have produced....

                    • 7. Re: Problem execute actions on jboss
                      Grim Shieldsson Newbie

                      If I undestand you correctly... It works fine in the junit, but not in the war when you load the process from the DB... I would start looking at class loader issues. All of my actions and other JBPM code is in WEB-INF/class. If your putting it somewhere else, you might have issues.. Assuming it is a class loader problem.

                      • 8. Re: Problem execute actions on jboss
                        Ronald van Kuijk Master

                        GrimShieldsson is correct and the pi being null is normal behaviour since the id is generated by hibernate and that is not used in the non-db tests

                        • 9. Re: Problem execute actions on jboss
                          Ansgar Thobe Newbie

                          Thanks for your replies!
                          GrimShieldsson, my problem is a little bit different.
                          everything works fine, as all my actions and jbpm code was in the web-inf/class of my war. But than someone told my, that i shouldn't run jbpm in the frontend.
                          So i put all the code in the backend and created a stateless session bean. these methods sould called form the jsf-managed beans for starting the process....
                          So far so good, i can start the process and the process instance runs through the single steps, but without execute the actions.
                          The junit test runs without failure so i guess, the problem is concerned with the jboss.
                          is it generally better to run jbpm in the war?
                          or is it maybee generally wrong to put the code in the backend?

                          • 10. Re: Problem execute actions on jboss
                            Ansgar Thobe Newbie

                            After a little more reading in the forum, i came to the conclusion, that having the jbpm code in the WEB-INF/class dir is the best way.
                            Am i right?
                            Is this just best practise or are there fundamental reasons?
                            Maybee i should make a new thread, that issue has a little realation to this one....