Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-3392

Event listener <field> element is not recognized when namespace is used

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • jBPM 4.x
    • jBPM 4.4
    • Runtime Engine
    • Hide

      The issue can be avoided by using the default namespace. Note that this workaround may be difficult if the process XML is generated via marshaling from java objects, e.g. using JAXB, or is generated by other tools that do not allow for control over XML namespaces.

      Show
      The issue can be avoided by using the default namespace. Note that this workaround may be difficult if the process XML is generated via marshaling from java objects, e.g. using JAXB, or is generated by other tools that do not allow for control over XML namespaces.
    • Hide

      Using the following event listener user code:

      TestEventListener.java
      package org.example;
      
      import org.apache.log4j.Logger;
      import org.jbpm.api.listener.EventListener;
      import org.jbpm.api.listener.EventListenerExecution;
      
      public class TestEventListener implements EventListener {
      
          public static Logger log = Logger.getLogger(TestEventListener.class);
      
          public String test;
          
          @Override
          public void notify(EventListenerExecution execution) throws Exception {
              log.info("notify: " + test);        
          }
      }
      

      deploy and execute the following process:

      <ns1:process key="event-test" name="event-test" xmlns:ns1="http://jbpm.org/4.4/jpdl" >
         <ns1:start name="start">
            <ns1:transition to="task1"/>
         </ns1:start>
         <ns1:task name="task1">
            <ns1:on event="start">
               <ns1:event-listener class="org.example.TestEventListener">
                  <ns1:field name="test">
                     <ns1:string value="test"/>
                  </ns1:field>
               </ns1:event-listener>
            </ns1:on>
            <ns1:transition to="end"/>
         </ns1:task>
         <ns1:end name="end"/>
      </ns1:process>
      

      The observed log output will be: "notify:null". However, if the process is deployed using the default namespace, like this:

      <process key="event-test" name="event-test" xmlns="http://jbpm.org/4.4/jpdl" >
         <start name="start">
            <transition to="task1"/>
         </start>
         <task name="task1">
            <on event="start">
               <event-listener class="org.example.TestEventListener">
                  <field name="test">
                     <string value="test"/>
                  </field>
               </event-listener>
            </on>
            <transition to="end"/>
         </task>
         <end name="end"/>
      </process>
      

      then the event listener works correctly and the observed output is: "notify:test"

      Show
      Using the following event listener user code: TestEventListener.java package org.example; import org.apache.log4j.Logger; import org.jbpm.api.listener.EventListener; import org.jbpm.api.listener.EventListenerExecution; public class TestEventListener implements EventListener { public static Logger log = Logger.getLogger(TestEventListener.class); public String test; @Override public void notify(EventListenerExecution execution) throws Exception { log.info( "notify: " + test); } } deploy and execute the following process: <ns1:process key= "event-test" name= "event-test" xmlns:ns1 = "http://jbpm.org/4.4/jpdl" > <ns1:start name= "start" > <ns1:transition to= "task1" /> </ns1:start> <ns1:task name= "task1" > <ns1:on event= "start" > <ns1:event-listener class= "org.example.TestEventListener" > <ns1:field name= "test" > <ns1:string value= "test" /> </ns1:field> </ns1:event-listener> </ns1:on> <ns1:transition to= "end" /> </ns1:task> <ns1:end name= "end" /> </ns1:process> The observed log output will be: "notify:null". However, if the process is deployed using the default namespace, like this: <process key= "event-test" name= "event-test" xmlns= "http://jbpm.org/4.4/jpdl" > <start name= "start" > <transition to= "task1" /> </start> <task name= "task1" > <on event= "start" > <event-listener class= "org.example.TestEventListener" > <field name= "test" > <string value= "test" /> </field> </event-listener> </on> <transition to= "end" /> </task> <end name= "end" /> </process> then the event listener works correctly and the observed output is: "notify:test"

    Description

      When deploying a process using namespace prefixes in the XML process definition, the <field> element within an <event-listener> element is not handled correctly, whereas it is handled correctly using the default namespace without prefixes.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jkranes@mitre.org Jon Kranes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: