4 Replies Latest reply on Jul 28, 2010 1:40 AM by mwohlf

    [Q] JBPM 4.4 JbpmException

    khoying

      I am trying to use the new JBPM 4.4 API to get the tranistions that are valid for the current process based on the processes current status.  However, I must be doing something wrong or must not understand something correctly.  Any help from the more knowledgeable would be greatly appreciated.

       

      I have tried the following:

       

      myProcess.findActiveExecutionIn(myState).getActivity();

       

      However, it get the following exception:

       

      Caused by: org.jbpm.api.JbpmException: no environment to get org.jbpm.pvm.internal.session.RepositorySession
          at org.jbpm.pvm.internal.env.EnvironmentImpl.getFromCurrent(EnvironmentImpl.java:203)
          at org.jbpm.pvm.internal.env.EnvironmentImpl.getFromCurrent(EnvironmentImpl.java:196)
          at org.jbpm.pvm.internal.model.ExecutionImpl.getProcessDefinition(ExecutionImpl.java:1182)
          at org.jbpm.pvm.internal.model.ExecutionImpl.getActivity(ExecutionImpl.java:1203)
          at org.jbpm.pvm.internal.model.ExecutionImpl.getActivity(ExecutionImpl.java:86)

       

      I have also attempted to get the the list of executions and process them.  However, the list is always empty.

       

      I am obviously missing something here with my understanding of the API.  Can someone enlighten me or point me in the right direction?

       

      Thank you!

        • 1. Re: [Q] JBPM 4.4 JbpmException
          mwohlf

          The problem is there is a database session needed if you call some of the methods, especially on the persistent objects like task, execution, process etc.... that's just the nature of mapping objects to a database, it is not a bug...

           

          you can:

          • stick with the methods of the services (RepositoryService, IdentityService, etc)
          • open/close an environment that manages the session for you (see developers guide section 6.5):
            EnvironmentImpl environment = (EnvironmentImpl) ((EnvironmentFactory)processEngine).openEnvironment();
            try {
              // do your stuff here
            } finally {
              environment.close();
            }
          • create a command that is executed by the process engine (see developers guide section 6.6):
            processEngine.execute(new Command() {
              public Object execute(Environment env) {
                // do your stuff here
                return null;
              }
            });
          • 2. Re: [Q] JBPM 4.4 JbpmException
            khoying

            Thank you so much for your assistance.  This was terrific and very helpful!

             

            Have a great week!

            • 3. Re: [Q] JBPM 4.4 JbpmException
              yushanyuan

              hello ,wohlfart:

               

                 i read the three points that you given. it's indeed helpful. but i have some trouble with the point 1,"stick with the methods of the services (RepositoryService, IdentityService, etc)". could you give an example or something? Thanks

              • 4. Re: [Q] JBPM 4.4 JbpmException
                mwohlf

                hi derek,


                for example using the taskService to get some subtasks like

                processEngine.getTaskService().getSubTasks(taskId);

                instead of task.getSubTask() when there is no hibernate session around.