6 Replies Latest reply on Dec 19, 2007 12:39 PM by mattowens

    contiunous JBPM errors

    mattowens

      Hi,

      I am writing a JBPM implmentation for a corporate system. Currently I am not deploying to an application server I am running the process locally as a set of unit tests. I am deploying the process definitions manually. Below is the code for the unit tests:

      public class testProcessManager
      {

      @BeforeClass
      public static void setup()
      {
      LBSJbpmInstance.createSchema();
      }

      @Test
      public void testCreateDefinition()
      {
      JbpmContext context = JbpmConfiguration.getInstance().createJbpmContext();

      try
      {
      URL u = this.getClass().getResource("/com/ProcessDefinition.xml");
      File f = new File(u.getFile());

      ProcessDefinition definition = ProcessDefinition.parseXmlReader(new FileReader(f));
      context.getGraphSession().deployProcessDefinition(definition);
      }
      catch (FileNotFoundException e)
      {
      Assert.fail(e.getMessage());
      }
      finally
      {
      context.close();
      }

      }

      @Test
      public void testCreateInstance()
      {
      JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();

      try
      {
      ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition(1);

      ProcessInstance processInstance = new ProcessInstance(processDefinition);

      ContextInstance contextInstance = (ContextInstance) processInstance.getContextInstance();
      contextInstance.createVariable("test", "test");

      processInstance.signal();

      jbpmContext.save(processInstance);
      }
      catch (Throwable t)
      {
      t.printStackTrace();
      Assert.fail(t.getMessage());
      }
      finally
      {
      jbpmContext.close();
      }
      }

      @AfterClass
      public static void teardown()
      {
      JbpmConfiguration.getInstance().dropSchema();
      }
      }


      This code throws the error: org.jbpm.JbpmException: closed JbpmContext in different order then they were created. This does not happen if i remove the processInstance.signal invocation.

      Can anyone explain the nature of this error.

      Thanks in advance
      M

        • 1. Re: contiunous JBPM errors
          kukeltje

          after creation put a saveandreload before the signalling. See jBPM unittests where this is also done.

          • 2. Re: contiunous JBPM errors
            mattowens

            Hi Ronald,

            Thanks for the quick response. Ok, im new to jbpm so don't really understand that response. Where can I get the latest jbpm unit tests? I'm using version 3.2.2.

            I found unit tests for 3.1.2 and located the save and reload method. I copied the code from there into my test and unfortunately it still doesn't work - i get exactly the same error (code below):

            @Test
            public void testCreateInstance()
            {
            JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();

            try
            {
            ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition(1);

            ProcessInstance processInstance = new ProcessInstance(processDefinition);

            ContextInstance contextInstance = (ContextInstance) processInstance.getContextInstance();
            contextInstance.createVariable("test", "test");

            jbpmContext.save(processInstance);
            jbpmContext.close();
            jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
            processInstance = jbpmContext.loadProcessInstance(processInstance.getId());

            processInstance.signal();
            }
            catch (Throwable t)
            {
            t.printStackTrace();
            Assert.fail(t.getMessage());
            }
            finally
            {
            jbpmContext.close();
            }
            }

            Any help would be much appreciated
            M

            • 3. Re: contiunous JBPM errors
              kukeltje

              the latest unittests are in CVS. The 3.2 release does not include the source anymore.

              • 4. Re: contiunous JBPM errors
                mattowens

                Could you please specify where i get the CVS url from? Im connecting to the JBPM source using fisheye and the unit tests specified within JBPM 3 (:/jbpm.3/test/jbpm/org/jbpm/graph/def/ProcessDefinitionDbTest.java ) in there are over 2 years old.

                Am i looking in the correct place?
                Thanks
                M

                • 5. Re: contiunous JBPM errors
                  kukeltje

                  make sure you see the only cvs-head files. The files you show are moved to a different location. :/jbpm.3/jpdl/jar/src/test

                  • 6. Re: contiunous JBPM errors
                    mattowens

                    thanks Roland i have just acquired the source using tourtoise cvs