cancel
Showing results for 
Search instead for 
Did you mean: 

How to use session bean with JavaDelegate in a Service Task

amir_kourani
Champ in-the-making
Champ in-the-making
Hi,

I create a java class JavaDelegateImpl that implements the JavaDelegate interface. In the bpmn model i configure the service task to use the previous class.

I am facing a problem when injecting a session bean in JavaDelegateImpl.

Is there a problem with the service class to inject session bean? and if so how to solve this problem? i need my service task to call a function in statless session bean.

Thank you.
5 REPLIES 5

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Can't you use CDI?

jbarrez
Star Contributor
Star Contributor
CDI would indeed be the easiest.

Or, if that's not possible see http://www.jorambarrez.be/blog/2011/01/13/tutorial-call-an-ejb-in-a-bpmn-2-0-process-using-activiti-...

Altough quite old post, I believe it is still valid.

amir_kourani
Champ in-the-making
Champ in-the-making
Actually i am using Liferay which is still not compatible with CDI. I will look at the above link, thank you.

amir_kourani
Champ in-the-making
Champ in-the-making
I have looked into the tutorial , but i am using EJB 3.1 instead of spring in my bussiness code.
1)does that make any problem?
2)what i need to really now about activi is : does activiti inject the serive class if its a session bean , or it will create it using constructor as a pojo class (pojo class cannot use @EJB or JNDI without a client module .
Thank you.

frederikherema1
Star Contributor
Star Contributor
You can always create a custom ExpressionManager. This allows you to lookup beans from EJB based on expressions used in activiti (e.g. a service-task with activiti:delegateExpression="${myEjbJavaDelegate}" or activiti:expression="${myEjbService.doStuff(execution.getVariable("var")}").

Take a look at org.activiti.spring.SpringExpressionManager, for example, this is the expression-manager that looks in the spring-context. We have one for OSGI and CDI as well, by default.