ClassCastException when setting Async Listener on EJB Executor
Issue
- We are using jBPM in embedded mode and trying to use Executor component as EJB. Is it possible to set Listener on executor, when it's used as EJB? We tried it but it failed with ClassCastException.
CODE:
package sample;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import org.jbpm.executor.impl.ExecutorServiceImpl;
import org.jbpm.services.ejb.api.DeploymentServiceEJBLocal;
import org.jbpm.services.ejb.api.ExecutorServiceEJB;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sample.MyAsyncJobListener;
@Singleton
@Startup
public class StartupBean {
private static final Logger logger = LoggerFactory.getLogger(StartupBean.class);
@EJB
DeploymentServiceEJBLocal deploymentService;
@EJB
ExecutorServiceEJB executorService;
@PostConstruct
public void init() throws Exception {
// init executor after kjar deployment
if (!executorService.isActive()) {
System.out.println(" ====== starting the custom executor ===== ");
System.setProperty("org.kie.executor.disabled", "false");
executorService.init();
}
// this command throw a ClassCastException...
((ExecutorServiceImpl) executorService).addAsyncJobListener(new MyAsyncJobListener());
}
}
Stacktrace:
Caused by: java.lang.ClassCastException: org.jbpm.services.ejb.api.ExecutorServiceEJB$$$view1 cannot be cast to org.jbpm.executor.impl.ExecutorServiceImpl
Environment
- Red Hat JBoss BPM Suite
- 6
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.