Autowired not working in JavaDelegate


#1

Hi,

can anybody guide me on following scenario.

I am trying to do some database operation in javadelegate class for my business logic. I am using spring4 with camunda bpm platform(7.7).

Following is piece of code trying to execute.

@Component
public class DatabaseLookupProcess implements JavaDelegate {

@Autowired
DatabaseLookupService dbLookupServ;

@Override
public void execute(DelegateExecution execution) throws Exception {
	
	dbLookupServ.getLookupData();
}

}

In above code i am getting DatabaseLookupService instance as null whereas this is working in non javadelegate class.
Please suggest how to resolve this issue?


#2

Hi @milindk,
how do you link the class from your BPMN model? Are you using Delegate Expression, as described here: https://docs.camunda.org/get-started/spring/service-task/ ?


#3

I am using delegateclass option and providing qualified classname com.camunda.DatabaseLookupProcess.


#4

This won’t work for version 7.7. But will work in 7.8. See https://app.camunda.com/jira/browse/CAM-7249.

For now try to use Delegate Expression.


#5

Hi Sdorokhova,

Thanks for guiding me. I have tried few option using Delegate Expression but it is not working.

Do you have any reference where some sample examples given on how to autowired using Delegate Expression. Please share me.


#6

hi,

you just have to set the java delegate expression to “#{databaseLookupProcess}”.


#7

Hi @milindk,
I’ve posted you the link to Getting Started. Have you checked it?

https://docs.camunda.org/get-started/spring/service-task/

IMO it illustrates exactly the same as you want to achieve.


#8

thanks OP for asking and thanks everyone else for responding. been having same issues (i’m also having health issues making me search for online pharmacy reviews and other things in this matter, but that’s another story) anyhow, i was having same issues as you and couldn’t resolve them all by myself. thanks for everything. i see that you people are more experienced than me, do you mind if i would have some questions? thanks!


#9

You guys are terrific !!!
Thanks Jerome for quick help. My code is working now.