Remote EJB invocation

I’ve been trying to invoke a remote EJB from within my process. Scenario is as follows :
1-Build project 1 including Entities, DAOs, exposed as remote EJBs (to be used by numerous applications). Interface as @Remote annotation, and implementation has @Stateless and @Named annotations.
2-Prepare a “process” war deployment only containing the model, processes.xml, EJB, and CDI maven dependencies, with reference to a DAO in project 1.

Whenever I invoke the process, I get the following :
Cannot resolve identifier ‘notificationsDAO’
at org.camunda.bpm.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
at org.camunda.bpm.engine.impl.juel.AstMethod.invoke(AstMethod.java:79)
at org.camunda.bpm.engine.impl.juel.AstMethod.eval(AstMethod.java:75)
at org.camunda.bpm.engine.impl.juel.AstEval.eval(AstEval.java:50)
at org.camunda.bpm.engine.impl.juel.AstNode.getValue(AstNode.java:26)
at org.camunda.bpm.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
at org.camunda.bpm.engine.impl.delegate.ExpressionGetInvocation.invoke(ExpressionGetInvocation.java:36)
at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:54)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:87)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:59)
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:55)
… 286 more

Environment : Wildfly 10, Camunda 7.5

Anything I’m missing?

Hi @ksinno,

could you please publish your process definition and delegate code?`

Cheers,
Askar

Hey there ,

Interface and EJB were in one WAR, and the BPMN in another WAR. Tried to upload the entire project, but zip files weren’t authorized.
There you go:

TestWorkflow.bpmn (3.2 KB)

INotificationsDAO:

package com.turnkey.test;

import javax.ejb.Remote;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.DelegateTask;

@Remote
public interface INotificationsDAO {
	 void sendNotification(DelegateExecution execution, DelegateTask task);
}

NotificationsDAO :

package com.turnkey.test;

import javax.ejb.Stateless;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@Stateless
@Named("notificationsDAO")
public class NotificationsDAO implements INotificationsDAO {

	private static Logger log = LoggerFactory.getLogger(NotificationsDAO.class);






	public void sendNotification(DelegateExecution execution, DelegateTask task) {
		log.info("Sending default notification from BPM.");
	}
}

Thanks for the code @ksinno,

do you have camunda-engine-cdi as dependency in your project? May be you could attach your pom.xml?

Cheers,
Askar

There you go!

ejb-war-pom.xml (3.4 KB)

project-war-pom.xml (1.4 KB)

@aakhmerov
If you need the full projects, let me know how I can provide you with them, if you don’t want to work with any unknowns to replicate the scenario.

@ksinno,

ideally you would publish code in github repository, possibly private and provide me the access to it. My username on github is the same.

The next step that I would do is to replace your DAO for now with a delegate available in your project with process definition and try to inject dao into the delegate with @Inject annotation.

Cheers,
Askar

Done, sent you a PM for the git repos

Hi @ksinno,

thanks for sharing, project looks fine to me. Could you try to add named resource to your project-war and inject DAO into it?

Cheers,
Askar

Hi,

You mean as per your first suggestion, java class and inject an EJB into that?

@ksinno,

yes. In general you have to verify that DAO is getting exposed as named resource properly. May be you can also increase logging level of application server to log named resources registered.

Cheers,
Askar

@aakhmerov,

I see all EJBS registered. However, is there something specific to check @Named classes other than exposed local/remote EJB classes?

@ksinno,

no not really, let’s see if injection in delegate would work out.

Cheers,
Askar

@aakhmerov,

@EJB(lookup="java:global/ejb-war/NotificationsDAO!com.turnkey.test.INotificationsDAO")
private INotificationsDAO notif;



@Override
public void notify(DelegateTask arg0) {
	notif.sendNotification(arg0.getExecution(), arg0);

} 

was null… Exposed as a remote interface and everything…