9 Replies Latest reply on Aug 26, 2009 11:56 AM by Ronald van Kuijk

    JBPM Java Task return value

    yukon Newbie

      Hi I am trying to run a Java task with return var as a part of my JBPM flow. I could successfully pass input arguments to the class mentioned in Java task but while getting value back from the Java task it throws exception saying ...

      at org.jbpm.pvm.internal.cmd.GetExecutionVariablesCmd.execute(GetExecutionVariablesCmd.java:60)
      at org.jbpm.pvm.internal.cmd.GetExecutionVariablesCmd.execute(GetExecutionVariablesCmd.java:36)
      at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
      at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:54)
      at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
      at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.getVariable(ExecutionServiceImpl.java:130)

      Please respond if someone has already faced and resolved this issue...


        • 1. Re: JBPM Java Task return value
          Ronald van Kuijk Master

          Although this post is totally not in line with http://www.jboss.org/index.html?module=bb&op=viewtopic&t=158610, can someone with the information in http://www.jboss.org/index.html?module=bb&op=viewtopic&t=149247 answer this post?

          (response by me to get this topic at the head of the forum, sorry for that)

          • 2. Re: JBPM Java Task return value
            Joram Barrez Master

            When you take a look at the source class at top of your stacktrace, you'll see that this exception occurs when the execution is null. Ie your process instance or subexecution does not exist (anymore). As Ronald states, without a complete unit test we can only guess about the cause.

            I see that Tom already added a more clear message in the trunk version.

            • 3. Re: JBPM Java Task return value
              yukon Newbie

              I do understand my execution is ending. But not able to find it ... Let me send you my jpdl file and code. My example code for Java task is working fine in the same project ...

              jpdl file


              Java code to start process...

              public void intiateProcess(ValueInObj inputObj) {
              try {
              deploymentId = repositoryService.createDeployment().addResourceFromClasspath("us/nj/state/dhs/njkids/jbpm/casecreationtrial.jpdl.xml").deploy();

              Map<String, Object> variables = new HashMap<String, Object>();
              variables.put("input", new Holder(inputObj));
              processInstance = executionService.startProcessInstanceByKey("casecreationtrial",variables);
              String pid = processInstance.getId();
              String out = (String)executionService.getVariable(processInstance.getId(), "answer");

              System.out.println("OUT Object ... "+out);
              } catch(Exception e) {
              System.out.println("Here I get exception ... "+e);

              } finally {
              try {
              }catch (Exception e) {System.out.println("Exception in finally ...");}




              • 4. Re: JBPM Java Task return value
                yukon Newbie

                Sorry... here is jpdl file replaced "<" with "#"

                #process name="casecreationtrial" xmlns="http://jbpm.org/4.0/jpdl"#
                #start g="36,75,100,47" name="start1"#
                #transition g="-49,-29" name="to Retrieve Application" to="Retrieve Application"/#
                #java class="com.mypackage.MyClass" g="173,70,175,58" method="test" var="answer" name="Retrieve Application" #
                #arg##object expr="#{input.apre.force}"/##/arg#
                #transition name="to end1" to="end1" g="-42,-18"/#
                #end g="481,69,92,49" name="end1"/#


                • 5. Re: JBPM Java Task return value
                  yukon Newbie

                  Guys, never mind ... I got the issue resolved...

                  Thanks and truly appreciate your help.

                  Ronald, sorry about trouble... I should have understand your hints earlier. But, i think its all about being new to JBPM.


                  • 6. Re: JBPM Java Task return value
                    Ronald van Kuijk Master

                    Thanks for getting back and glad that it works.

                    If you do not mind I like to give you some additional tips.

                    First of all it is no problem being new to something and asking questions, not at all. We welcome all new users :-) But there are reasons behind my comments on how and where to post. It keeps the forums clean and topics well... on topic and thus easier for others to find if they use search functionality.

                    Secondly, us asking for a fully integrated unittest instead of just some code and a processdefinition also has a reason. It is the most explicit way of stating what you do and expect and we can fairly easily run it on our side and see/debug what happens if it really is a bug in jBPM.

                    Thirdly, regarding posting something, many forums (including this one) have options for putting in code/xml. In this forum use the [c o d e] tag (without spaces, also see the preview button) The # instead of < is not needed then.

                    Regarding debugging, that is also something you can do yourself and seeing the processinstance is null is something can see then yourself.

                    And last but not least, if you solve something, it is good practise to not also report back that you solved it, but e.g. also confirm that we were right, or that it was another issue and than also state what that other issue is. Others can learn from that.

                    What I still do not get (talking about confusion ;-)) is what you mean by

                    I do understand my execution is ending. But not able to find it ...

                    And that you say it works with a java task, but what you post *has* a java task...

                    And for everybody: If there are no wait states in your processdefinition, it is ended when the startProcessInstanceXXX returns. When it ends, jBPM removes it from the active list and put it in the history, so you cannot retrieve variables, or whatever anymore based on id's. The 4.1 release will, instead of throwing an exeption, tell you the instance cannot be found.

                    • 8. Re: JBPM Java Task return value
                      yukon Newbie

                      Not really, I have gathered project structure from different places and mix match ... what not ...
                      Well, wanted to thank you for all your suggestions ... Don't want to take much space of forum for writing irrelevant things in here...
                      Take care

                      • 9. Re: JBPM Java Task return value
                        Ronald van Kuijk Master

                        hahahaha.... spot on...