I have been working on this for about a week, and I can't get my JSF backing bean to find a simple stateless session bean in my EJBs. At this point, I'm wondering, is JNDI the right tool for this job?
One of the common mistakes that happen is that while deploying the bean you bind the bean to some jndi name and later try looking up the bean with some other jndiname. This ofcourse is not intentional, but because of some mistake in writing the deployment descriptors in your application.
If I could just make it dump out what it has in it, I might be able to find out if things are being put in wrong
You can use the jmx-console for this. Access the following url:
On the jmx-console web page, you will see a lot of services listed. One of them will be service=JNDIView . Click on the same. You will see a page which will show the methods and attributes of this jndi service. Click on the Invoke button, next to the list operation. You will see a dump of the objects that are bound to the jndi
Try it out and let us know of any issues.
THANK YOU! That gave me a dump of every bean in JNDI and let me find exactly what I'm looking for. Ok, it is as simple as it should be.
Now I have one more question which should be even easier:
Is it possible to use the @EJB annotation to inject a stateless session bean from my EJBs into my JSF backing bean? I assume that all I need to do is have the backing bean member be of the right class, and use @EJB, and that's it, right? I tried that and it doesn't work, and I looked around on Google and it sounds like that may not be supported yet, as a limitation within Tomcat. Is this true?
As another way of stating it: If I can grab it from an InitialContext I should be able to have it injected with @EJB, right? Because that isn't working. How does the @EJB decide which bean to grab? I assume it looks at the class name, so if I have:
@EJB private myBean;
it will look in JNDI for "MyAppName/myBean/local", right? Because that's in the context but it isn't injecting.
Frankly speaking, i havent worked with EJB3. You might post your ejb-jar.xml and jboss.xml(the relevant portions), so that someone out here might be able to help you out.
In case anybody finds this thread: Yes, @EJB injection in JSF backing beans is not supported right now by Tomcat. This is somewhat obscure if you only look at JSF, but also a limitation for JSPs or Servlets. Explained here: http://docs.jboss.org/ejb3/app-server/tutorial/ear/ear.html
Seam helps, it can bind JSF UI components directly to EJBs without any backing beans.