0 Replies Latest reply on Nov 23, 2009 3:31 PM by Mac Ferguson

    Possible bug(s) in variable mapping in JBPM/ESB integration

    Mac Ferguson Newbie

      I have a question regarding the implementation of mapping of variables from a jBPM process instance to ESB messages by the EsbActionHandler class.

      I have been trying to figure out a way to pass a static value from a jBPM process node to an ESB service using only the out-of-the-box ESB/BPM integration, and I noticed that the Mapping.parseMappingElement(Element mappingElement) method parses the value of a "default" attribute from the bpmToEsbVars/mapping element of the process definition. It stores that value in the mapping instance along with the MVEL expressions and scope:

      Mapping mapping = new Mapping();
       mapping.setEsb(mappingElement.attributeValue(Constants.ESB_VARNAME_TAG));
       mapping.setBpm(mappingElement.attributeValue(Constants.BPM_VARNAME_TAG));
       mapping.setDefaultValue(mappingElement.attributeValue(Constants.DEFAULT_VALUE_TAG));
      



      If the JbpmObjectMapper.getObjectFromVariableMap(...) returns a null for the mapping, an attempt is made to find the variable in the execution context.

       Object object = getObjectFromJBpmVariableMap(isPrcScope, mapping.getBpm(), ctxInstance, token);
       //if that fails then try to get it from the ExecutionContext
       if (object==null) {
       object = MVEL.getProperty(mapping.getBpm(), executionContext);
       }
      


      In my test code where the variable does not exist the following uncaught exceptrion is thrown by the MVEL.getProperty() call:

      15:15:16,343 ERROR [GraphElement] action threw exception: unable to resolve property: actionId
      org.mvel.CompileException: unable to resolve property: actionId
       at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:289)
       at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:110)
       at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.get(ReflectiveAccessorOptimizer.java:94)
       at org.mvel.MVEL.getProperty(MVEL.java:572)
       at org.jboss.soa.esb.services.jbpm.JBpmObjectMapper.setOnEsbMessage(JBpmObjectMapper.java:140)
       at org.jboss.soa.esb.services.jbpm.JBpmObjectMapper.mapFromJBpmToEsbMessage(JBpmObjectMapper.java:81)
       at org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler.execute(EsbActionHandler.java:103)
       at org.jbpm.graph.def.Action.execute(Action.java:126)
       at sun.reflect.GeneratedMethodAccessor542.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
       at org.jbpm.graph.def.Action_$$_javassist_98.execute(Action_$$_javassist_98.java)
       at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:284)
       at org.jbpm.graph.def.Node.execute(Node.java:414)
       at sun.reflect.GeneratedMethodAccessor528.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
       at org.jbpm.graph.def.Node_$$_javassist_145.execute(Node_$$_javassist_145.java)
       at org.jbpm.job.ExecuteNodeJob.execute(ExecuteNodeJob.java:28)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
       at org.jbpm.job.Job_$$_javassist_149.execute(Job_$$_javassist_149.java)
       at org.jbpm.job.executor.JobExecutorThread.executeJob(JobExecutorThread.java:170)
       at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:60)
      Caused by: org.mvel.PropertyAccessException: unable to resolve property: actionId
       at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:383)
       at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:258)
       ... 28 more
      



      Even if that didn't happen the default value from the mapping is never used.

      Should I log a JIRA ticket for either of these (I'm wondering if there is intent behind not using the default attribute)?