9 Replies Latest reply on Feb 25, 2010 2:22 PM by swiderski.maciej

    [jBPM4.1] - No Environment Exception

      Hi

       

      Can anyone please guide me how to fix this. When i am trying to get the outgoing transitions from an activity/state i end up with below exception.

      Can anyone please  suggest me why i am getting this exception and how to fix this.

       

      org.jbpm.api.JbpmException: no environment to get org.jbpm.pvm.internal.session.RepositorySession
      at org.jbpm.pvm.internal.env.Environment.getFromCurrent(Environment.java:196)
      at org.jbpm.pvm.internal.env.Environment.getFromCurrent(Environment.java:189)
      at org.jbpm.pvm.internal.model.ExecutionImpl.getProcessDefinition(ExecutionImpl.java:1096)
      at org.jbpm.pvm.internal.model.ExecutionImpl.getActivity(ExecutionImpl.java:1118)

       

      Thanks for your valuable reply

        • 1. Re: [jBPM4.1] - No Environment Exception
          kukeltje

          Mike,

           

          It is good practice to provide us with a small unittest that demonstrates the problem. We cannot guess what you try to do...

           

          Cheers,

           

          Ronald

          • 2. Re: [jBPM4.1] - No Environment Exception

            Hi Ronald,

             

            Thanks for your reply and also sorry for the confusion.

             

            This is what i am trying to to.

            Using Query API and process instance id i am getting ProcessInstance in my code.
            After getting the ProcessInstance, using ExecutionImpl i am trying to get the Outgoing Transitions for a state in a workflow.

             

            ProcessInstance processInstance =  getExecutionService().createProcessInstanceQuery().processInstanceId(pProcessInstanceID).uniqueResult();
            ExecutionImpl activeExecution = ((ExecutionImpl)processInstance).findActiveExecutionIn(StateName);
            List<Transition> outgoingTransitionList = activeExecution.getActivity().getOutgoingTransitions();

             

            With this code i am getting 'No Environment Exception'. Did i miss something over here?

            • 3. Re: [jBPM4.1] - No Environment Exception
              kukeltje

              Mike,

               

              Thanks for the response, but to be honest, it is no unittest. But I can partially get some info from it.

               

              What you do is using *Impl classes. These should normally not be used since they are in the internal package and not in the api package. These classes are normally used in commands (that are in turn used in the services). They are 'bootstrapped' with the correct data among which is the 'Environment'

               

              But interestingly, (as you can see in a post in the dev forum), the current trunk and upcomming 4.4 release has some support for this, at least regarding accessing transitions in other nodes then tasks.

               

              Cheers,

               

              Ronald

              • 4. Re: [jBPM4.1] - No Environment Exception

                Hi Ronald

                 

                Thanks for clarifying me. I hope now you can understand my unittest.

                 

                Below is my sample process definition xml.

                 

                <process name="TestProcess">
                   <start name="start1">
                      <transition name="TN1" to="state1"/>
                   </start>
                   <state name="state1">
                      <transition name="S1T1" to="state2"/>
                      <transition name="S1T2" to="state3"/>
                      <transition name="S1T3" to="complete"/>
                   </state>
                   <state name="state2">
                <transition name="S2T1" to="complete"/>
                   </state>
                   <state name="state3">
                <transition name="S3T1" to="complete"/>
                   </state>
                   <end name="complete" state="completed">
                </process>

                 

                In my application, now the exeuction is at state1 (<state name="state1">"). Here i need to get the list of possible transitions at state1.

                What  would be the correct way to achieve this. Which API i should use to get the outgoing transitions at a particular state.

                 

                Please help me. Thanks a lot!

                • 5. Re: [jBPM4.1] - No Environment Exception
                  kukeltje

                  Mike,

                   

                  I already mentioned in my previous reply that this is in trunk and will be in 4.4 and that this (including some code) is in the developer forum...So there currently is no (good) way to do this, other then change the jBPM source yourself in one way or another.

                   

                  Ronald

                  • 6. Re: [jBPM4.1] - No Environment Exception

                    thanks for your clarification

                    • 7. Re: [jBPM4.1] - No Environment Exception
                      kukeltje
                      I have to add here that there is no 'other' (good) way of doing this other then using the source from trunk
                      • 8. Re: [jBPM4.1] - No Environment Exception

                        Hi Ronald

                         

                        Can you please provide me the link to get the source from trunk as i have no idea about the trunk.

                         

                        Thanks

                        Mike

                        • 9. Re: [jBPM4.1] - No Environment Exception
                          swiderski.maciej

                          Hi,

                           

                          here you can find quite good description how to get source and how to build it.

                          http://community.jboss.org/wiki/jBPM4BuildingfromSource

                           

                          Cheers,

                          Maciej