6 Replies Latest reply on Dec 14, 2009 3:53 AM by kukeltje

    JBPM 4.2 Sub-Processs Not able to access Variables

      Hi

      I have main Process < Main-Proc > invokes sub-process <Sub-Proc > on certain decision node.

      Main-Proc will be started by providing
      Process -Id
      Domain -Id
      and set of variables.

      i could able to access those variables in my main-proc (execution.getVaraibles() )
      but i couldn;t get the same inside my sub-proc.
      even i couldn't say sup-proc execution.getParent().getVariable(). parent is comming as null. ???

      any idea its a bug or i am i doing wrong.


        • 1. Re: JBPM 4.2 Sub-Processs Not able to access Variables

          my jpdl being

          main-proc::










          <sub-process name="metaonly-ingest" sub-process-key="wf_metaonly_ingestion"
          g="130,367,132,53">

          <event-listener class="org.sae.services.jbpm4.StartExternalWork" />




          </sub-process>

          <end-error name="failed" g="472,528,48,48"/>

          • 2. Re: JBPM 4.2 Sub-Processs Not able to access Variables
            sebastian.s

            Please use the code-tags to supply your process definition. If possible please also supply a unit test demonstrating your problem.

            • 3. Re: JBPM 4.2 Sub-Processs Not able to access Variables

              main process

              <?xml version="1.0" encoding="UTF-8"?>
              <process name="wf_ingest_book" version="1" xmlns="http://jbpm.org/4.2/jpdl">
               <start g="264,19,48,48" name="startIngestBook">
               <transition g="-73,-18" name="trDecideType" to="decideType"/>
               </start>
               <decision g="271,125,48,48" name="decideType">
               <handler class="org.sae.services.jbpm4.DecideTypeHandler" />
               <transition g="-95,-18" name="trMetaOnlyIngest" to="metaonly-ingest"/>
               <transition g="499,235:-48,-18" name="trFailed" to="failed"/>
               </decision>
               <sub-process name="metaonly-ingest" sub-process-key="wf_metaonly_ingestion"
               g="130,367,132,53">
               <transition name="trSuccess" to="succeeded" g="-62,-18"/>
               <transition name="trFailed" to="failed" g="-62,-18"/>
               </sub-process>
               <end g="122,443,48,48" name="succeeded"/>
               <end-error g="387,459,48,48" name="failed"/>
              </process>
              


              SupProcess
              <?xml version="1.0" encoding="UTF-8"?>
              <process name="wf_metaonly_ingestion" version="1" xmlns="http://jbpm.org/4.2/jpdl">
               <start g="333,26,48,48" name="startMetaOnlyIngestion">
               <transition g="-113,-22" name="trMetaOnlyIngest" to="stateMetaOnlyIngest"/>
               </start>
               <custom g="275,201,163,52"
               name="stateMetaOnlyIngest"
               class="org.sae.services.jbpm4.IngestBookActivity">
               <transition g="234,231:-42,-18" name="trSuccess" to="succeeded"/>
               <transition g="494,231:-48,-18" name="trFailure" to="failed"/>
               </custom>
               <end g="209,356,48,48" name="succeeded"/>
               <end-error g="471,367,48,48" name="failed"/>
              </process>
              


              JBPMTestCase
              public void testDoDirty() {
               ProcesssInformationService pisrv = JBPMServices
               .getProcesssInformationService();
               System.out.println("TEST");
               // ProcessInstance processInstance =
               // pisrv.startProcess("wf_ingest_book");
               String pid = "wf_ingest_book";
               String cid = System.currentTimeMillis() + "";
               Map<String,Object> variables = new HashMap<String,Object>();
               variables.put("product-type","book");
               variables.put("ingest-type","meta-only");
               variables.put("prod-cd", "AE-21");
               variables.put("c-id", "");//Some CID Number
               ProcessInstance processInstance = pisrv.startProcess(pid,variables, cid);
              


              i can access all these variables in my main process - any event,lisenter,java module hooks.

              but these same variables are not able to my sub-process custom module.

              i tried to get parent.getProcessInstance.getVariable also.. parent is comming as null..


              ublic class IngestBookActivity implements ExternalActivityBehaviour {
               public void signal(ActivityExecution execution, String signalName,
               Map<String, ?> parameters) throws Exception {
              
               System.out.println( " Parameters "+parameters);
               String prodCd = (String)execution.getVariable("prod-cd");
               String prodType = (String)execution.getVariable("product-type");
              /** both prod-cd, prod-type comming as null */
               IngestionControl pojo = new IngestionControl();
               pojo.setProdCd(prodCd);
               pojo.setProdType(prodType);
              
               String executionPath = "trSuccess";
               try {
               doIngestion(pojo);
               System.out.println(" IngestBook Activity --- Book Ingested Successfully ");
               } catch (Exception e) {
               e.printStackTrace();
               executionPath = "trFailure";
               }
               execution.take( executionPath);
               }
              


              • 4. Re: JBPM 4.2 Sub-Processs Not able to access Variables
                kukeltje

                Please read the documentation http://docs.jboss.com/jbpm/v4/userguide/html_single/#subprocess. It's all in there...

                • 5. Re: JBPM 4.2 Sub-Processs Not able to access Variables
                  sebastian.s

                  Might be related to your problem:

                  https://jira.jboss.org/jira/browse/JBPM-2485

                   

                  Also refer to the post mentioned in the JIRA (regarding a workaround):

                  http://community.jboss.org/thread/118912?tstart=0

                   

                  Ronald, did I get you right when saying you proposed passing the variables into the sub-process by using the parameter-attribute in the process definition of the main process as it is described in the documentation?

                  • 6. Re: JBPM 4.2 Sub-Processs Not able to access Variables
                    kukeltje
                    Ronald, did I get you right when saying you proposed passing the variables into the sub-process by using the parameter-attribute in the process definition of the main process as it is described in the documentation?

                     

                    Yes, since that is what is the way to do it at the moment.