0 Replies Latest reply on Dec 16, 2009 12:55 AM by minghei

    blocking at  jbpmContext.getGraphSession()

      Hello,

       

      I am having some problem when running the following application in a multi-thread program

      Working in single thread. everything can run smoothly. However, running in multi-thread I found that the thread always block at the line

       

      graphSession = jbpmContext.getGraphSession();

       

      How can I solve this ? Is there another way to implement it ?

       

      thank you

       

      public class Workflow {

       

          private static String configString = "";
          private static JbpmConfiguration jbpmConfiguration = null;

       

          static {
              try {
                  configString = FileTools.readFileAsString("config\\jbpm.cfg.xml");
                  jbpmConfiguration = JbpmConfiguration.parseXmlString(configString);
              } catch (Exception ex) {
                  System.out.println("Error while loading configuration");
              }
          }

          public static void createInstance(String definitionName, String processID) throws Exception {
              JbpmContext jbpmContext = null;
              GraphSession graphSession = null;
              try {
                  jbpmContext = jbpmConfiguration.createJbpmContext();
                  graphSession = jbpmContext.getGraphSession();

       

                  ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition(definitionName);
                  ProcessInstance processInstance =  new ProcessInstance(processDefinition);
                  processInstance.setKey(processID);
                  jbpmContext.save(processInstance);

       

              } catch (Exception ex) {
                  ex.printStackTrace();
              } finally {
                  jbpmContext.close();
              }
          }

      }