0 Replies Latest reply on Nov 5, 2018 7:30 AM by Vikram Nisarga

    Rule task is not working in sub process

    Vikram Nisarga Newbie

      Hi,

      I'm trying to insert values into my bpm process variables using a business rule task, It's is working when there is only one rule task in the process hierarchy, When i add another rule task in the child process, It is throwing null pointer exception. Please help me in resolving the issue, I've attached the relevant bpmn2 files and drl files

      I'm using jbpm 5.4, below is the code used for triggering the process

       

      @@public static void main( String[] args )
          {
          System.out.println("starting jbpm");
              KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
              knowledgeBuilder.add(new ClassPathResource("GlobalChild.bpmn2"), ResourceType.BPMN2);
              knowledgeBuilder.add(new ClassPathResource("GlobalParent.bpmn2"), ResourceType.BPMN2);
              knowledgeBuilder.add(new ClassPathResource("GlobalConfiguration_Rule.drl"), ResourceType.DRL);
              knowledgeBuilder.add(new ClassPathResource("GlobalConfiguration_Rule2.drl@@@@"), ResourceType.DRL);
              KnowledgeBase knowledgeBase = knowledgeBuilder.newKnowledgeBase();
             final StatefulKnowledgeSession statefulKnowledgeSession = knowledgeBase.newStatefulKnowledgeSession();
              statefulKnowledgeSession.addEventListener(new RuleAwareProcessEventLister());
              
              
              
              HashMap<string, object=""> hashMap = new HashMap<string, object="">();
              hashMap.put("variable1", "4002");
              ProcessInstance processInstance = statefulKnowledgeSession.startProcess("GlobalPOC", hashMap);
             statefulKnowledgeSession.fireAllRules();
              
              System.out.println(""+processInstance.getId());
             statefulKnowledgeSession.dispose();
          }

       

      I'm getting the below error

       

      Exception in thread "main" [Error: null pointer: $processInstance.getVariable("sub_variable1").toString()]
      [Near : {... $processInstance.getVariable(" ....}]
                   ^
      [Line: 1, Column: 1]
      at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:427)
      at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)
      at org.mvel2.ast.ASTNode.optimize(ASTNode.java:159)
      at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115)
      at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:114)
      at org.mvel2.MVELRuntime.execute(MVELRuntime.java:86)
      at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123)
      at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119)
      at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:113)
      at org.mvel2.MVEL.executeExpression(MVEL.java:930)
      at org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:73)
      at org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:52)
      at org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:218)
      at org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:175)
      at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:133)
      at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
      at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
      at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:302)
      at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:254)
      at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:366)
      at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:327)
      at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:950)
      at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:894)
      at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
      at org.jbpm.process.instance.impl.RuleAwareProcessEventLister.afterVariableChanged(RuleAwareProcessEventLister.java:69)
      at org.drools.event.ProcessEventSupport.fireAfterVariableChanged(ProcessEventSupport.java:154)
      at org.jbpm.process.instance.context.variable.VariableScopeInstance.setVariable(VariableScopeInstance.java:79)
      at org.jbpm.process.instance.AbstractProcessInstanceFactory.createProcessInstance(AbstractProcessInstanceFactory.java:47)
      at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:184)
      at org.jbpm.process.instance.ProcessRuntimeImpl.createProcessInstance(ProcessRuntimeImpl.java:156)
      at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:137)
      at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1152)
      at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:320)
      at com.jbpm.test.test.App.main(App.java:48)
      Caused by: java.lang.NullPointerException
      at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:393)
      ... 33 more