@Autowired annotation not working when implementing "JavaDelegate" interface

Hi All,

I am implementing a listener to send notifications which implements JavaDelegate interface. I couldn’t autowire other service classes from this listener class.

Please find my implementation below,

Kindly suggest a solution !

Thanks in advance,
Sriram B

You’re trying to autowire to a ServiceTask: that won’t work. A ServiceTask is a modeling element.

You’re probably looking for execution.getCurrentFlowElement() which will give you the current element?

Thanks for responding @joram

Its a typo… Actually I am trying to autowire a service class and not the service task… Sorry for the typo.

In my case, i need to access some methods written in other service classes. But i couldn’t autowire those service classes from this listener class.

How are you using this class? If it’s a Spring bean, it should be referenced with a delegateExpression and not through class (otherwise a new object gets created outside of the Spring container).

Sorry @joram i couldn’t get your question… can you pls detail it out ?

Hi @sriramb

How do you call the notificationListener in your process / case?

Do you use the delegateExpression for it?

<... delegateExpression="${notificationListener}" ... />

Hi @amporsim

I am not using delegateExpression. I am using listener to call this listener class

Hey @sriramb,

In order for @Autowired to work you’ll need to expose your class as a bean and use delegateExpression. When using class Flowable is not going to inject Spring dependencies in your class.