cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using Service Task with Delegate Expression in OSGi with fields

schmke
Champ in-the-making
Champ in-the-making
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?
2 REPLIES 2

schmke
Champ in-the-making
Champ in-the-making
FWIW, I have written an ELResolver that extends BlueprintELResolver and directly looks up the service from the OSGi service registry rather than using Blueprint.  If the service task is registered using Declarative Services or an activator, things work fine as there is now no proxy in play.

I don't need this new ELResolver to be in Activiti, but is there interest in having it be?  I'd be happy to contribute it.

trademak
Star Contributor
Star Contributor
Hi,

Would be very welcome as a contribution to Activiti. If you could a bit of documentation to the user guide for it as well that be really great as well. Could you create a pull request on Github?

Best regards,