AnsweredAssumed Answered

Problem using Service Task with Delegate Expression in OSGi with fields

Question asked by schmke on Apr 17, 2016
Latest reply on Apr 26, 2016 by trademak
I am using Activiti 5.19 in Karaf and everything has been working fine thus far.  I want to have Java Service Tasks be reusable and so I am deploying them as their own bundles and using Delegate Expressions to refer to them, and using the BlueprintELResolver in my engine configuration.  This is also working fine.

Except …

Everything works fine if the Java Service Task just needs to operate on process instance variables.  It sees all those just fine.  However, if I want to instead or in addition set fields, this is not working.  When the engine tries to invoke the service, this exception is thrown:

org.activiti.engine.ActivitiIllegalArgumentException: Field definition uses unexisting field '<fieldName>' on class Proxy734e4f6e_ba1c_46f0_a2f2_fb552c9ba51d

The problem seems to be this.  Setting fields is done using reflection by looking for a setter matching the field name or finding the instance variable to set directly.  This works fine when the service is a direct instance of the Java class in question.  However, this delegate lookup that uses BlueprintELResolver (or BlueprintContextELResolver too it appears) is using Blueprint which proxies these classes, and since these setters are not part of the JavaDelegate interface, they nor the variables, can be found using reflection and the field is considered existing.

Is this a known issue or limitation?  Are we simply unable to set fields when using Delegate Expressions in Karaf with the BlueprintELResolver?

Yes, I could just punt and use variables, but that imposes a coupling between the variables the process sets and this specific Java Service Task and I'd prefer to not tie them together and be able to set fields.

Is there an alternate approach to accomplishing the same thing without the proxies brought on by Blueprint?  Or do I need to write an ELResolver that just does native OSGi stuff or perhaps uses Declarative Services so as to avoid the proxies?