4 Replies Latest reply on Jan 22, 2013 9:08 PM by martin steve

    How to get parameters in script action

    martin steve Newbie

      Hello everybody.I have a question, then need your help.

       

      I start a process by session and set a map of parameters.The name of a parameter is "person". As follows:

       

      KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

      kBuilder.add(ResourceFactory.newClassPathResource("hello.bpmn"),

                      ResourceType.BPMN2);

      KnowledgeBase kBase = kBuilder.newKnowledgeBase();

      StatefulKnowledgeSession kSession = kBase.newStatefulKnowledgeSession();

      Map<String, Object> params = new HashMap<String, Object>();   

      Person person = new Person();

      person.setName("martin");

      params.put("person", person);

      ProcessInstance pInstance = kSession.startProcess("com.sample.hello", params);

       

      then I think print the name of person in a script action.Code as follows:

       

      System.out.println(person.getName());

       

      I run my codes and then get a exception:

       

      [main] ERROR builder.impl.KnowledgeBuilderImpl.newKnowledgeBase  - Process Compilation error : org.drools.lang.descr.ProcessDescr@79024994

           defaultPackage/Process_defaultPackage_Sample_Process_4419562b234b4de3b32f940de6602c9f.java (11:468) : person cannot be resolved

       

      Exception in thread "main" java.lang.IllegalArgumentException: Could not parse knowledge.

          at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:79)

          at com.sample.JBPMTest.main(JBPMTest.java:23)

       

      How to get parameters in script action?

      Thank you!