13 Replies Latest reply on Jan 20, 2006 4:03 PM by lappi_79

    trying to come to grips with delpoyment

      Hi all,
      I'm struggling coming to understand the deployment process. I've created my process definitions using the eclipse plugin. I'm trying to deploy my process definition to the sample jbpm-server included in the starter's kit.
      Since its the sample server, it is running on JBoss 4.0.2 under JDK 1.5.0_05 on Windows XP.
      I've updated the sample jbpm-server to go to oracle by updating the jbpm.properties file in jbpm.sar.cfg.jar in the jbpm.sar under the deploy directory. I also wrote an MBean that I've deployed also under the deploy directory that allows me to deploy a process' processinstance.xml file.
      Here's the method:

      public long createNewProcessInstance(String processName) {
       long processId = 0;
       LOG.debug("createNewProcessInstance:" + processName);
       if (processName != null && processName.trim().length() > 0) {
       LOG.debug("creating processInstnace");
       try {
       LOG.debug("about to get JbpmSessionFactory");
       InitialContext iniCtx = new InitialContext();
       jbpmSessionFactory = (JbpmSessionFactory) iniCtx.lookup("java:/jbpm/JbpmSessionFactory");
       LOG.debug("got JbpmSessionFactory");
       }
       catch (Exception e) {
       LOG.error("coulnd't buildJbpmSessionFactory", e);
       return 0;
       }
      
       try {
       JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
       LOG.debug("got a jbpmSession");
       // ... and begin a transaction on the persistence session.
       jbpmSession.beginTransaction();
       LOG.debug("after beginTransaction");
      
       // Now we can query the database for the process definition that we
       // deployed above.
       ProcessDefinition processDefinition =
       jbpmSession
       .getGraphSession()
       .findLatestProcessDefinition("payrollProcessed");
       LOG.debug("got processDefinition=" + processDefinition);
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       LOG.debug("got processInstance=" + processInstance);
       processId = processInstance.getId();
       LOG.debug("processInstance id:" + processId);
       LOG.debug("about to commit");
       jbpmSession.commitTransaction();
       LOG.debug("after commit");
       // And close the jbpmSession.
       jbpmSession.close();
       }
       catch (Exception e) {
       LOG.error("createNewProcessInstance: cant createProcessInstance", e);
       }
       }
       LOG.debug("JbpmHelper: ending createNewProcessInstance:" + processName);
       return processId;
       }
      


      It works and I'm able to generate process instances with another MBean call. Everything persists to Oracle fine, the definitions and the instances.

      My problem is I'm trying to delpoy a processdefinition.xml file with ActionHandler classes. Since I'm just deploying the .xml file, I don't think that jbpm is able to locate these classes, although I can't see any error messages.
      - I've placed the java classes (with the correct packages) into my MBean .sar file.
      - I've placed the java classes (with the correct packages) into the server/lib folder calling it jbpmhandlers.jar
      - I've placed the same jbpmhandlers.jar into the jbpm.sar folder

      I don't know if the problem is the handler classes can't be found or my deployment method (using just the XML) is keeping the classes from being deployed correctly. I've also updated the jbpm.properties to write temp files to c:\jbpm.data, but I've not seen anything written there after multiple delpoyments of this process defition.

      Any ideas? Should I use another method of deploying my definition? Is there a clear set of instructions describing how to deploy the .par file?

      Thanks!

        • 1. Re: trying to come to grips with delpoyment
          kukeltje

          jbpm has a deploy servlet. Throw the .par file at it and it runs. You can also use the deploy option from the GPD, but the server has to be running on 127.0.0.1:8080 currently. A third option is to use the deploy.process ant task. See the build file to see what it does.

          Regarding the jbpmhandlers.jar. Do you want them separate from the .par file? That is fine, but are you sure they are on the classpath? Try just putting the jar file in the jboss deploy directory and see if that works.


          btw... _ADP???? Automatic Data Processing?

          • 2. Re: trying to come to grips with delpoyment

            Ok, I finally did get it working, but it was a bit of work.

            1. I tried using the GPD to deploy (the eclipse plugin). I figured out (I couldn't find it documented) that to deploy you need to right click on a .par directory and select "Deploy Process Archive". I had various eclipse errors telling me to check the error log (which I couldn't find). So, I could not get this to work.

            2. I then investigated the DeployServlet servlet. Unfortunately, it is not included in the jbpm.war file as supplied (security perhaps?). So I recompiled the jbpm-webapp-3.0.jar and added it. It deployed the process definition and it created the directory c:\jbpm-dir\files-XXX after every deploy. However, I noticed that changes to the Action classes were not being picked up and looking at the logs I noted that JBpm was looking for the classes in a directory files-XXX where XXX was empty and one more than the one created by the deployer. So back to the forums and I noted that this is a known error:
            http://www.jboss.com/index.html?module=bb&op=viewtopic&t=69772
            The only reason the process had been working was by putting my action classes in the jbpm.sar file I created jbpm was finding it. So I again commented out the jbpm.files.dir in jbpm.properties and removed my Action classes from my sar and the deployment worked.
            I called deployservlet thusly:
            http://localhost:8080/jbpm/deploy?archive=file:///myfile.par after creating the .par archive defined in the proper format.
            Moreover, changes are being reflected in the process definitions correctly without having to resort to putting my action classes in the classpath.

            Just a quick comment - Getting this thing working is really making me a little nuts. Is this par (pun not intended) for the course?

            • 3. Re: trying to come to grips with delpoyment
              davidsan1001

              I had my challenges as well. I'm getting it down now. Here are my quick steps.

              1) Use JBoss 4.0.2
              2) Fresh jBPM
              3) modify build.properties (gives system paths to jBPM and JBoss)
              4) ant tasks from build.xml: compile, build, build.processes
              5) ant tasks from build.deploy.xml (create.jbpm.configuration, start.jboss)

              That should get you going and using websale. To deploy your own .par
              1) At jbpm/src/process.examples/ add a directory <process name>.par
              2) Inside there should be your processdefinition.xml, gpd.xml, and processimage.jpg
              3) Add any java packages created in GPD to jpbm/src/java.examples
              3) modify ant taget build.process in build.xml (at about lines 182-193). This should reflect your <process name>.par, package name, temporary staging directory.
              4) Repeat the 5 steps mentioned above

              Phew, that is my take on deployment. I've seen a few others. There is more than one way to get things to work.

              • 4. Re: trying to come to grips with delpoyment
                aguizar

                 

                I had various eclipse errors telling me to check the error log

                The log is located in file WORKSPACE_DIR/.metadata/.log - Eclipse prints detailed operation messages here.

                • 5. Re: trying to come to grips with delpoyment
                  kukeltje

                  jbpm/jboss has to be running locally on 127.0.0.1:8080 for deployment from the gpd to work. This is a current limitation.

                  Regarding the files, there is another thread on this issue. I myself have never seen it.

                  The deployservlet is in the webapp. We have not taken security into account yet since it is in our opinnion probably not the right solution to go into production. For development it is realy handy

                  • 6. Re: trying to come to grips with delpoyment

                     

                    The deployservlet is in the webapp. We have not taken security into account yet since it is in our opinnion probably not the right solution to go into production. For development it is realy handy


                    Ron,
                    Just to be clear, it is in the latest version of jbpm 3.0.1. I was using version 3.0 which did not have the delpoyservlet in the jbpm.war. I had a bit of time invested in my 3.0 jbpm installation (e.g. its configured for connectivity to IBM MQ series as the remote JMS provider etc...) so I didn't want to upgrade right now. I probably should in the future.

                    What I actually did was cannibalize the DelpoyServlet and added it to my MBean. Here's the code if you're interested:

                    public String deployParFile(String fullQualifiedFile, String processName) throws Exception {
                     String msg = null;
                     long prevProcessId;
                     LOG.debug("deploying archive " + fullQualifiedFile);
                     try {
                     LOG.debug("about to get JbpmSessionFactory");
                     InitialContext iniCtx = new InitialContext();
                     jbpmSessionFactory = (JbpmSessionFactory) iniCtx.lookup("java:/jbpm/JbpmSessionFactory");
                     LOG.debug("got JbpmSessionFactory");
                     LOG.debug("getting jbpmsession");
                     JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                     ProcessDefinition processDefinition =
                     jbpmSession
                     .getGraphSession()
                     .findLatestProcessDefinition(processName);
                     prevProcessId = processDefinition.getId();
                     LOG.debug("previous processDefinitionId: " + prevProcessId);
                     LOG.debug("closing jbpmsession");
                     jbpmSession.close();
                     }
                     catch (Exception e) {
                     LOG.debug("couldnt find previous definition of process:" + processName);
                     prevProcessId = 0;
                     }
                    
                     try {
                     URL archiveUrl = new URL(fullQualifiedFile);
                     ZipInputStream zis = new ZipInputStream(archiveUrl.openStream());
                     ProcessArchiveDeployer.deployZipInputStream(zis);
                     zis.close();
                     }
                     catch (Exception e) {
                     e.printStackTrace();
                     }
                    
                     try {
                     JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                     ProcessDefinition processDefinition =
                     jbpmSession
                     .getGraphSession()
                     .findLatestProcessDefinition(processName);
                     long newProcessId = processDefinition.getId();
                     if (newProcessId != prevProcessId) {
                     msg = "Loaded:" + fullQualifiedFile + " successfully." + "previous processDefinitionId: " + prevProcessId + " new processDefinitonid:" + newProcessId;
                     LOG.debug(msg);
                     }
                     else {
                     msg = "Unsuccessful in loading process definition:" + fullQualifiedFile;
                     LOG.debug(msg);
                     }
                     LOG.debug("closing jbpmsession");
                     jbpmSession.close();
                    
                     }
                     catch (Exception e) {
                     msg = "Unsuccessful in loading process definition:" + fullQualifiedFile;
                     LOG.debug(msg);
                     }
                    
                     return msg;
                     }
                    


                    The reason I'm so hung up on MBeans is I really need to test jbpm on the server Running tests and esp stress tests from my local JVM is pointless - I need to do a P.O.C. and see if jbpm will handle our expected load. By putting the hooks into my MBean:
                    interface JbpmHelperMBean {
                     public void deployProcessDefinition(String xmlString) throws Exception;
                     public String deployParFile(String fullQualifiedFile, String processName) throws Exception;
                     public void lookup(String jndiName) throws Exception;
                     public String createNewProcessInstance(String processName);
                     public String signalProcess(String processId, String transition);
                     public String getProcessState(String processId, String tokenStr);
                     public boolean processHasEnded(String processId);
                    }
                    

                    I can run my unit tests and stress tests by invoking the appropriate method and have the work occur in JBoss on the server. I'm not sure if I'm over complicating things, but I really don't know how else to accomplish this easily. All of the example code, while very illustrative, spawns and executes the jbpm processes within the client JVM. This tests the functionality of your process definitions, but it doesn't indicate whether the server can handles 1000 messages in a minute and what the latency is. Any suggestions on an easier way to accomplish this would be helpful.



                    • 7. Re: trying to come to grips with delpoyment
                      kukeltje

                      this is nice, a .par deployer by dropping it in te deploy dir of JBoss? Or do I miss something (i'm not an mbean expert)

                      • 8. Re: trying to come to grips with delpoyment

                        Ron,
                        It's not exactly auto deploy but all it is a an MBean (jbpmhelper) that is accessed through the JBoss JMX console that provides the convenience functions that I listed above. For deployment, as stated above I included the method:
                        deployParFile() which takes two parameters:

                        fullQualifiedFile java.lang.String A fully qualified file name
                        processName java.lang.String The Name of the process

                        This will ease the deployment process for our release management staff, all they do is specify the patch to a .par file and click "invoke". If you're interested I can provide the complete code for the MBean, let me know how to do this.
                        As for the sample code above, I made the change to prepend the string "file:///" to whatever is passed in, then all the release manager needs to do is provide a path to the new process def.



                        • 9. Re: trying to come to grips with delpoyment
                          tom.baeyens

                          i have been thinking about a process deployer for jboss as well, but couldn't find a good match. since the lifecycle of a process deployment is different for process archives then for all other deployed archives on jboss.

                          the basic question it comes down to is: how does the deployer know it should deploy a .par ? when should a redeploy occur ?

                          i came to the conclusion that deploy should always be an admin function that requires a human to trigger it. so i like the MBean approach.

                          maybe we can list all the files in the jboss/server/default/deploy/processarchives directory in one method and provide another method to deploy them.

                          good thinking. thanks !

                          regards, tom.

                          regards, tom.

                          • 10. Re: trying to come to grips with delpoyment
                            alal007

                             

                            If you're interested I can provide the complete code for the MBean, let me know how to do this.
                            As for the sample code above, I made the change to prepend the string "file:///" to whatever is passed in, then all the release manager needs to do is provide a path to the new process def.


                            paul_adp: appreciate if you can share your complete code.

                            • 11. Re: trying to come to grips with delpoyment
                              alal007

                              " If you're interested I can provide the complete code for the MBean,"

                              paul_adp
                              Coluld you please provide complete code. Appreciate your help

                              • 12. Re: trying to come to grips with delpoyment

                                Sorry for the delay - still trying to get this thing off the ground. Here's the code for the .sar that I've found very useful for deployment AND JUNIT testing...

                                JbpmHelperMBean excuse the formatting logging etc... its functional not pretty ;)

                                package jmx.service.jbpm;
                                
                                import jmx.service.jndi.JNDIMBean;
                                import javax.naming.NamingException;
                                import org.apache.log4j.Logger;
                                import jmx.service.jms.JMSMBean;
                                
                                interface JbpmHelperMBean {
                                 public void deployProcessDefinition(String xmlString) throws Exception;
                                 public String deployParFile(String fullQualifiedFile, String processName) throws Exception;
                                 public void lookup(String jndiName) throws Exception;
                                 public String createNewProcessInstance(String processName);
                                 public String signalProcess(String processId, String transition);
                                 public String getProcessState(String processId, String tokenStr);
                                 public boolean processHasEnded(String processId);
                                }
                                


                                JbpmHelper
                                package jmx.service.jbpm;
                                import javax.naming.InitialContext;
                                import javax.jms.JMSException;
                                import jmx.service.jms.JMS;
                                import org.apache.log4j.*;
                                
                                import org.jbpm.db.GraphSession;
                                import org.jbpm.db.JbpmSession;
                                import org.jbpm.db.JbpmSessionFactory;
                                import org.jbpm.db.JbpmSchema;
                                import org.jbpm.graph.def.ProcessDefinition;
                                import org.jbpm.graph.exe.ProcessInstance;
                                import org.jbpm.graph.exe.Token;
                                
                                import java.io.IOException;
                                import java.io.PrintWriter;
                                import java.net.URL;
                                import java.util.zip.ZipInputStream;
                                import org.jbpm.jpdl.par.ProcessArchiveDeployer;
                                import javax.management.Notification;
                                import javax.management.MBeanRegistration;
                                import javax.management.NotificationListener;
                                
                                public class JbpmHelper implements JbpmHelperMBean {
                                 private static Logger LOG = Logger.getLogger(JbpmHelper.class);
                                 static JbpmSessionFactory jbpmSessionFactory = null;
                                 private String processDefinitionStr =
                                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " +
                                 " " +
                                 "<process-definition " +
                                 " name=\"payrollProcessed\"> " +
                                 " <start-state name=\"start\"> " +
                                 " <transition name=\"request DS work request\" to=\"create DS work request\"></transition> " +
                                 " </start-state> " +
                                 " <node name=\"create DS work request\"> " +
                                 " <action class=\"jmx.service.jbpm.NIActionHandler\"></action> " +
                                 " <transition name=\"work request created\" to=\"DS work request created\"></transition> " +
                                 " </node> " +
                                 " <node name=\"DS work request created\"> " +
                                 " <transition name=\"CoreDB load succeeded\" to=\"CoreDB loaded\"></transition> " +
                                 " <transition name=\"CoreDB loaded failed\" to=\"CoreDB load fails\"></transition> " +
                                 " </node> " +
                                 " <node name=\"CoreDB loaded\"> " +
                                 " <transition name=\"register CoreDB loaded\" to=\"end1\"></transition> " +
                                 " </node> " +
                                 " <node name=\"CoreDB load fails\"> " +
                                 " <transition name=\"dont retry load\" to=\"end1\"></transition> " +
                                 " <transition name=\"retry load\" to=\"create DS work request\"></transition> " +
                                 " </node> " +
                                 " <end-state name=\"end1\"></end-state> " +
                                 "</process-definition> ";
                                
                                 public void lookup(String jndiName) throws Exception {
                                 LOG.debug("JbpmHelper: called lookup:" + jndiName);
                                 InitialContext iniCtx = new InitialContext();
                                 if (jndiName == null || jndiName.trim().length() == 0) {
                                 jndiName = "java:/jbpm/JbpmSessionFactory";
                                 }
                                 LOG.debug("looking up:" + jndiName);
                                 Object o = iniCtx.lookup(jndiName);
                                 jbpmSessionFactory = (JbpmSessionFactory) o;
                                 LOG.debug("got JbpmSessionFactory:" + jbpmSessionFactory);
                                 }
                                
                                 public String createNewProcessInstance(String processName) {
                                 long processId = 0;
                                 LOG.debug("createNewProcessInstance:" + processName);
                                 if (processName != null && processName.trim().length() > 0) {
                                 LOG.debug("creating processInstnace");
                                 try {
                                 LOG.debug("about to get JbpmSessionFactory");
                                 InitialContext iniCtx = new InitialContext();
                                 jbpmSessionFactory = (JbpmSessionFactory) iniCtx.lookup("java:/jbpm/JbpmSessionFactory");
                                 LOG.debug("got JbpmSessionFactory");
                                 }
                                 catch (Exception e) {
                                 LOG.error("coulnd't buildJbpmSessionFactory", e);
                                 return null;
                                 }
                                
                                 try {
                                 JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                                 LOG.debug("got a jbpmSession");
                                 // ... and begin a transaction on the persistence session.
                                 jbpmSession.beginTransaction();
                                 LOG.debug("after beginTransaction");
                                
                                 // Now we can query the database for the process definition that we
                                 // deployed above.
                                 ProcessDefinition processDefinition =
                                 jbpmSession
                                 .getGraphSession()
                                 .findLatestProcessDefinition(processName);
                                 LOG.debug("got processDefinition=" + processDefinition);
                                 ProcessInstance processInstance = new ProcessInstance(processDefinition);
                                 LOG.debug("got processInstance=" + processInstance);
                                 processId = processInstance.getId();
                                 LOG.debug("processInstance id:" + processId);
                                 LOG.debug("about to commit");
                                 jbpmSession.commitTransaction();
                                 LOG.debug("after commit");
                                 // And close the jbpmSession.
                                 jbpmSession.close();
                                 }
                                 catch (Exception e) {
                                 LOG.error("createNewProcessInstance: cant createProcessInstance", e);
                                 }
                                 }
                                 LOG.debug("JbpmHelper: ending createNewProcessInstance:" + processName);
                                 return processId + "";
                                 }
                                
                                 public String signalProcess(String processIdStr, String transition) {
                                 LOG.debug("createNewProcessInstance:" + processIdStr + " transition:" + transition);
                                 String currentState = null;
                                 long processId = Long.parseLong(processIdStr);
                                 if (processId > 0) {
                                 LOG.debug("signalProcess");
                                 try {
                                 LOG.debug("about to get JbpmSessionFactory");
                                 InitialContext iniCtx = new InitialContext();
                                 jbpmSessionFactory = (JbpmSessionFactory) iniCtx.lookup("java:/jbpm/JbpmSessionFactory");
                                 LOG.debug("got JbpmSessionFactory");
                                 }
                                 catch (Exception e) {
                                 LOG.error("coulnd't buildJbpmSessionFactory", e);
                                 return null;
                                 }
                                
                                 try {
                                 JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                                 LOG.debug("got a jbpmSession");
                                 // ... and begin a transaction on the persistence session.
                                 jbpmSession.beginTransaction();
                                 LOG.debug("after beginTransaction");
                                
                                 // Now we can query the database for the process definition that we
                                 // deployed above.
                                 ProcessInstance processInstance =
                                 jbpmSession
                                 .getGraphSession()
                                 .loadProcessInstance(processId);
                                 if (processInstance == null) {
                                 LOG.debug("unable to load processInstance with processId:" + processId);
                                 return null;
                                 }
                                
                                 LOG.debug("got processInstance=" + processInstance);
                                 processId = processInstance.getId();
                                 LOG.debug("processInstance id:" + processId);
                                
                                 Token token = processInstance.getRootToken();
                                 LOG.debug("got token=" + token);
                                 currentState = token.getNode().getName();
                                 LOG.debug("current state:" + currentState);
                                 LOG.debug("transition='" + transition + "'" + " length=" + transition.trim().length());
                                 // Let's signal the process execution
                                 if (transition == null || transition.trim().length() == 0) {
                                 token.signal();
                                 }
                                 else {
                                 // add error checking for existence of transition name here
                                 token.signal(transition);
                                 }
                                 currentState = token.getNode().getName();
                                 LOG.debug("current state:" + currentState);
                                // token.signal("work request created");
                                // LOG.debug("current state:" + token.getNode().getName());
                                // token.signal("CoreDB load succeeded");
                                // LOG.debug("current state:" + token.getNode().getName());
                                // token.signal("register CoreDB loaded");
                                // LOG.debug("current state:" + token.getNode().getName());
                                 LOG.debug("about to commit");
                                 jbpmSession.commitTransaction();
                                 LOG.debug("after commit");
                                 // And close the jbpmSession.
                                 jbpmSession.close();
                                 }
                                 catch (Exception e) {
                                 LOG.error("cant signalProcess", e);
                                 }
                                 }
                                 LOG.debug("JbpmHelper: ending signalProcess:" + processId);
                                 return currentState;
                                 }
                                
                                 public void deployProcessDefinition(String xmlString) throws Exception {
                                 LOG.debug("JbpmHelper: called deployProcessDefinition:" + xmlString);
                                 if (xmlString != null && xmlString.trim().length() > 0) {
                                 processDefinitionStr = xmlString;
                                 }
                                 LOG.debug("processDefinitionStr=" + processDefinitionStr);
                                 try {
                                 LOG.debug("about to get JbpmSessionFactory");
                                 InitialContext iniCtx = new InitialContext();
                                 jbpmSessionFactory = (JbpmSessionFactory) iniCtx.lookup("java:/jbpm/JbpmSessionFactory");
                                 LOG.debug("got JbpmSessionFactory");
                                 }
                                 catch (Exception e) {
                                 LOG.error("coulnd't buildJbpmSessionFactory", e);
                                 }
                                
                                 try {
                                 LOG.debug("about to getJbpmSchema().createSchema()");
                                 JbpmSchema schema = jbpmSessionFactory.getJbpmSchema();
                                 boolean createSchema = !schema.hasJbpmTables();
                                 LOG.debug("need to createSchema:" + createSchema);
                                 if (createSchema) {
                                 LOG.debug("creating JbpmSchema");
                                 jbpmSessionFactory.getJbpmSchema().createSchema();
                                 }
                                 else {
                                 LOG.debug("JbpmSchema exists, so don't create it");
                                 }
                                 LOG.debug("after getJbpmSchema().createSchema()");
                                 }
                                 catch (Exception e) {
                                 LOG.error("couldn't getJbpmSchema().createSchema()", e);
                                 }
                                
                                 ProcessDefinition processDefinition = null;
                                 try {
                                 LOG.debug("about to ProcessDefinition.parseXmlString");
                                 processDefinition = ProcessDefinition.parseXmlString(processDefinitionStr);
                                 LOG.debug("after ProcessDefinition.parseXmlString");
                                 }
                                 catch (Exception e) {
                                 LOG.error("couldn't ProcessDefinition.parseXmlString");
                                 }
                                
                                 try {
                                 LOG.debug("getting jbpmsession");
                                 JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                                 // ... and begin a transaction on the persistence session
                                 LOG.debug("beginning trans");
                                 jbpmSession.beginTransaction();
                                
                                 // Save the process definition in the database
                                 LOG.debug("saving process definition");
                                 jbpmSession.getGraphSession().saveProcessDefinition(processDefinition);
                                
                                 // Commit the transaction
                                 LOG.debug("commiting trans");
                                 jbpmSession.commitTransaction();
                                 // And close the jbpmSession.
                                 LOG.debug("closing jbpmsession");
                                 jbpmSession.close();
                                 LOG.debug("done loading definition");
                                 }
                                 catch (Exception e) {
                                 LOG.error("couldn't load process definition");
                                 }
                                 }
                                
                                 public String deployParFile(String fullQualifiedFile, String processName) throws Exception {
                                 String msg = null;
                                 long prevProcessId;
                                 fullQualifiedFile = "file:///" + fullQualifiedFile;
                                 LOG.debug("deploying archive " + fullQualifiedFile);
                                 try {
                                 LOG.debug("about to get JbpmSessionFactory");
                                 InitialContext iniCtx = new InitialContext();
                                 jbpmSessionFactory = (JbpmSessionFactory) iniCtx.lookup("java:/jbpm/JbpmSessionFactory");
                                 LOG.debug("got JbpmSessionFactory");
                                 LOG.debug("getting jbpmsession");
                                 JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                                 ProcessDefinition processDefinition =
                                 jbpmSession
                                 .getGraphSession()
                                 .findLatestProcessDefinition(processName);
                                 prevProcessId = processDefinition.getId();
                                 LOG.debug("previous processDefinitionId: " + prevProcessId);
                                 LOG.debug("closing jbpmsession");
                                 jbpmSession.close();
                                 }
                                 catch (Exception e) {
                                 LOG.debug("couldnt find previous definition of process:" + processName);
                                 prevProcessId = 0;
                                 }
                                
                                 try {
                                 URL archiveUrl = new URL(fullQualifiedFile);
                                 ZipInputStream zis = new ZipInputStream(archiveUrl.openStream());
                                 ProcessArchiveDeployer.deployZipInputStream(zis);
                                 zis.close();
                                 }
                                 catch (Exception e) {
                                 e.printStackTrace();
                                 }
                                
                                 try {
                                 JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                                 ProcessDefinition processDefinition =
                                 jbpmSession
                                 .getGraphSession()
                                 .findLatestProcessDefinition(processName);
                                 long newProcessId = processDefinition.getId();
                                 if (newProcessId != prevProcessId) {
                                 msg = "Loaded:" + fullQualifiedFile + " successfully." + "previous processDefinitionId: " + prevProcessId + " new processDefinitonid:" + newProcessId;
                                 LOG.debug(msg);
                                 }
                                 else {
                                 msg = "Unsuccessful in loading process definition:" + fullQualifiedFile;
                                 LOG.debug(msg);
                                 }
                                 LOG.debug("closing jbpmsession");
                                 jbpmSession.close();
                                
                                 }
                                 catch (Exception e) {
                                 msg = "Unsuccessful in loading process definition:" + fullQualifiedFile;
                                 LOG.debug(msg);
                                 }
                                
                                 return msg;
                                 }
                                
                                 public String getProcessState(String processIdStr, String tokenStr) {
                                 long processId = Long.parseLong(processIdStr);
                                
                                 if (processId > 0) {
                                 LOG.debug("getProcessState:" + processId);
                                 try {
                                 LOG.debug("about to get JbpmSessionFactory");
                                 InitialContext iniCtx = new InitialContext();
                                 jbpmSessionFactory = (JbpmSessionFactory) iniCtx.lookup("java:/jbpm/JbpmSessionFactory");
                                 LOG.debug("got JbpmSessionFactory");
                                 }
                                 catch (Exception e) {
                                 LOG.error("coulnd't buildJbpmSessionFactory", e);
                                 return null;
                                 }
                                
                                 try {
                                 JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                                 ProcessInstance processInstance =
                                 jbpmSession
                                 .getGraphSession()
                                 .loadProcessInstance(processId);
                                 if (processInstance == null) {
                                 LOG.debug("unable to load processInstance with processId:" + processId);
                                 return null;
                                 }
                                 if (tokenStr == null || tokenStr.trim().length() == 0 || tokenStr.equals("/")) {
                                 Token token = processInstance.getRootToken();
                                 return token.getNode().getName();
                                 }
                                 else {
                                 Token token = processInstance.findToken(tokenStr);
                                 return token.getNode().getName();
                                 }
                                 }
                                 catch (Exception e) {
                                 return "unable to get process:" + processId + " state.";
                                 }
                                 }
                                 return null;
                                 }
                                
                                 public boolean processHasEnded(String processIdStr) {
                                 long processId = Long.parseLong(processIdStr);
                                 ProcessInstance processInstance = null;
                                
                                 LOG.debug("processHasEnded:" + processId);
                                 processInstance = getProcessInstance(processId);
                                 if (processInstance != null) {
                                 return processInstance.hasEnded();
                                 }
                                 else {
                                 return false;
                                 }
                                 }
                                
                                 ProcessInstance getProcessInstance(long processId) {
                                 ProcessInstance processInstance = null;
                                 try {
                                 LOG.debug("about to get JbpmSessionFactory");
                                 InitialContext iniCtx = new InitialContext();
                                 jbpmSessionFactory = (JbpmSessionFactory) iniCtx.lookup("java:/jbpm/JbpmSessionFactory");
                                 LOG.debug("got JbpmSessionFactory");
                                 }
                                 catch (Exception e) {
                                 LOG.error("coulnd't buildJbpmSessionFactory", e);
                                 return null;
                                 }
                                 try {
                                 JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                                 return processInstance =
                                 jbpmSession
                                 .getGraphSession()
                                 .loadProcessInstance(processId);
                                 }
                                 catch (Exception e) {
                                 LOG.error("coulnd't obtain processInstance with processId:" + processId, e);
                                 return null;
                                 }
                                 }
                                }
                                


                                jboss-service.xml
                                <server>
                                
                                 <mbean code="jmx.service.jbpm.JbpmHelper" name="jmx.service.jbpm:service=JbpmHelper"
                                 description="jBPM Helper Service"
                                 xmbean-dd="META-INF/jbpmhelper-xmbean.xml">
                                 <depends>jboss:service=Naming</depends>
                                 </mbean>
                                
                                </server>
                                


                                jbpmhelper-xmbean.xml
                                <?xml version="1.0" encoding="UTF-8"?>
                                <!DOCTYPE mbean PUBLIC
                                 "-//JBoss//DTD JBOSS XMBEAN 1.0//EN"
                                 "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_0.dtd">
                                
                                <mbean>
                                 <description>jbpm helper MBean</description>
                                 <descriptors>
                                 <!--
                                 <persistence persistPolicy="Never" persistPeriod="10" persistLocation="data/DataSyncAdaptor.data" persistName="jbpm helper mbean"/>
                                 <currencyTimeLimit value="10"/>
                                 <state-action-on-update value="keep-running"/>
                                 -->
                                 </descriptors>
                                
                                 <class>jmx.service.jbpm.JbpmHelper</class>
                                
                                
                                 <!-- Operations
                                 <operation>
                                 <description>The start lifecycle operation</description>
                                 <name>start</name>
                                 </operation>
                                 <operation>
                                 <description>The stop lifecycle operation</description>
                                 <name>stop</name>
                                 </operation>
                                 <operation>
                                 <description>The create lifecycle operation</description>
                                 <name>create</name>
                                 </operation>
                                 <operation>
                                 <description>The destroy lifecycle operation</description>
                                 <name>destroy</name>
                                 </operation>
                                 -->
                                
                                 <operation impact="ACTION">
                                 <description>Looks up jbpm session factory</description>
                                 <name>lookup</name>
                                 <parameter>
                                 <description>The JNDI name of the session factory</description>
                                 <name>jndiName</name>
                                 <type>java.lang.String</type>
                                 </parameter>
                                 <return-type>void</return-type>
                                 </operation>
                                
                                 <operation impact="ACTION">
                                 <description>Creates a new process instance</description>
                                 <name>createNewProcessInstance</name>
                                 <parameter>
                                 <description>The Name of the process</description>
                                 <name>processName</name>
                                 <type>java.lang.String</type>
                                 </parameter>
                                 <return-type>java.lang.String</return-type>
                                 </operation>
                                
                                 <operation impact="ACTION">
                                 <description>Deploys an archived .par file</description>
                                 <name>deployParFile</name>
                                 <parameter>
                                 <description>A fully qualified file name</description>
                                 <name>fullQualifiedFile</name>
                                 <type>java.lang.String</type>
                                 </parameter>
                                 <parameter>
                                 <description>The Name of the process</description>
                                 <name>processName</name>
                                 <type>java.lang.String</type>
                                 </parameter>
                                 <return-type>java.lang.String</return-type>
                                 </operation>
                                
                                 <operation impact="ACTION">
                                 <description>Signals a process</description>
                                 <name>signalProcess</name>
                                 <parameter>
                                 <description>The process Id</description>
                                 <name>processId</name>
                                 <type>java.lang.String</type>
                                 </parameter>
                                 <parameter>
                                 <description>The transition to take</description>
                                 <name>transition</name>
                                 <type>java.lang.String</type>
                                 </parameter>
                                 <return-type>java.lang.String</return-type>
                                 </operation>
                                
                                 <operation impact="ACTION">
                                 <description>gets the current state of a process</description>
                                 <name>getProcessState</name>
                                 <parameter>
                                 <description>The process Id</description>
                                 <name>processId</name>
                                 <type>java.lang.String</type>
                                 </parameter>
                                 <parameter>
                                 <description>The token to return the state of</description>
                                 <name>token</name>
                                 <type>java.lang.String</type>
                                 </parameter>
                                 <return-type>java.lang.String</return-type>
                                 </operation>
                                
                                 <operation impact="ACTION">
                                 <description>returns whether a process has ended</description>
                                 <name>processHasEnded</name>
                                 <parameter>
                                 <description>The process Id</description>
                                 <name>processId</name>
                                 <type>java.lang.String</type>
                                 </parameter>
                                 <return-type>boolean</return-type>
                                 </operation>
                                
                                </mbean>
                                


                                For those unfamilar with MBeans
                                Build your .sar file (named Whatever.sar) with the following structure:
                                \jmx\server\jbpm\JbpmHelper.class
                                \jmx\server\jbpm\JbpmHelperMBean.class
                                \meta-inf\jboss-service.xml
                                \meta-inf\jbpmhelper-xmbean.xml


                                Drop it into your \deploy directory and access it as:
                                http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jmx.service.jbpm%3Aservice%3DJbpmHelper

                                Call the deployParFile supplying the fully qualified name (e.g. c:\blah\foo.par) and specify the name of the process defintion (e.g. MyProcess).
                                That should do it. Hope this is helpful.

                                • 13. Re: trying to come to grips with delpoyment
                                  lappi_79

                                  Can these steps be usefull in deploying pars on jbpm+tomcat+mysql configuration ?

                                  Thanks!