I am trying to implement a Listener with a field injection.
I call a ExecutionListener via Delegate Expression, which is found correctly. I set a Field Injection field with a name, as Type String, with a value.
In my code the injection is referenced to as Type Expression. I try to call the String value with getValue(execution).toString();in the Listeners notify-method, but i always get a NullPointerException, because the injected Object is always null.
Any Ideas of why this fails? I´ve done field injections often with service or send tasks but never with listeners. Is there any difference i should be aware of?
Hi all, it’s an older post but I needed the same functionality for ExecutionListener and ended up with NPEs. @nikola.koevski 's note to follow the documentation was the key to solve the issue:
You have to use the type Expression for the injected field even if you inject just a String. Then you can call:
fieldName.getValue(execution).toString();
One should still check against NPs if the same Listener is used in the BPMN without field injection or injection result depends on other variables etc.