1

I’ve tried CDI injection and @EJB injection of Stateless EJBs in a Rivr dialog. They don’t work. I’ve also tried JNDI lookup of the EJBs through the Global JNDI name but I get following error (note I am using java:global but I get this message):

A JNDI operation on a java:comp/env name cannot be completed because the current thread is not associated with a Java Enterprise Edition application component. This condition can occur when the JNDI client using the java:comp/env name does not occur on the thread of a server application request. Make sure that a Java EE application does not run JNDI operations on java:comp/env names within static code blocks or in threads created by that application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on java:comp/env names.

Is there anyway I can inject or locate CDI @Named or EJBs in a Rivr dialog?

thanks Ignacio

gawi
  • 13,940
  • 7
  • 42
  • 78
icordoba
  • 1,834
  • 2
  • 33
  • 60
  • I am not familiar with Rivr, but from the [documentation page](https://github.com/nuecho/rivr/wiki/Getting-Started) I do not see any connection of the library to Java EE platform. In order to access EJB and CDI beans, you need to run your application as a WAR or EAR on a JavaEE application server. Can you post some code snippets of how you use Rivr and how you want to inject an EJB using JNDI? – OndroMih Sep 17 '15 at 10:43
  • It seems like the more appropriate question is how are you deploying your rivr based application? – John Ament Sep 17 '15 at 21:23
  • Hello, the app is run as a standard War. The problem was not related to how I am running the Rivr app as I was using a JEE7 app server and Injecting CDI and EJBs successfully in other places of my code. The problem was that Rivr default Dialogs are ran in a thread out of JEE or Servlet context so EJBs were not accessible even in the JNDI tree. I just posted the solution hoping it can help someone else. – icordoba Sep 19 '15 at 16:44

1 Answers1

1

I examined the Spring example in Rivr cookbook and found that the DialogFactories are executed in the ServletThread. This allowed me to perform a standard JNDI lookup using the Global JNDI name successfully and pass the EJBs to the Dialog being created.

Rivr team confirmed this by email and I am now successfully accessing EJBs that way.

I could not perform standard @Inject or @EJB injections but the JNDI "traditional" solution worked for me.

icordoba
  • 1,834
  • 2
  • 33
  • 60