-
1. Re: JNDI EJB lookup in jboss5.1.0 GA
wdfink Nov 20, 2010 5:46 AM (in response to varsha7)What about the dependency injection? You using local interface that make me feel you are inside the container or inside your ear, right?
Do you try
@EJB BeanLocal myBean;
This will inject the local interface before your code is called.
-
-
3. Re: JNDI EJB lookup in jboss5.1.0 GA
varsha7 Nov 23, 2010 11:09 AM (in response to jaikiran)Thank you. I read that chapter and tried it out but am having problems. My ejb is deployed in an ear file.
Here is my code:
import org.jboss.ejb3.annotation.LocalBinding;
import org.jboss.ejb3.annotation.RemoteBinding;@Stateless
@LocalBinding(jndiBinding="ABCBean/local")
@RemoteBinding(jndiBinding="ABCBean/remote")public class ABCBean implements ABCLocal, ABCRemote {
.... }
I lookup for that ejb from a servlet in a different package.try
{
return (ABCRemote)ctx.lookup("ABCBean/remote");
}
catch (NameNotFoundException e) { ..
}I get a javax.naming.NameNotFoundException: ABCBean/remote could not be found during jboss startup. I am on jboss 5.1.0GA.
Thanks -
4. Re: JNDI EJB lookup in jboss5.1.0 GA
jaikiran Nov 23, 2010 11:13 AM (in response to varsha7)When are you doing that lookup in the servlet? In its init() method? Is that a load-on-startup servlet? Make sure that the beans are first deployed and then the lookup is done. You can also check the "JNDIView" MBean to list the jndi names of the beans you deployed.
-
5. Re: JNDI EJB lookup in jboss5.1.0 GA
varsha7 Nov 23, 2010 11:23 AM (in response to jaikiran)The lookup is done in the servlet's init() method. I checked the JNDIView and see the bean deployed there. How do I know if the bean is deployed first before the lookup is done? Is the JNDI view listed in the order of deployment?
-
6. Re: JNDI EJB lookup in jboss5.1.0 GA
jaikiran Nov 23, 2010 11:30 AM (in response to varsha7)Varsha Hardikar wrote:
The lookup is done in the servlet's init() method.
I guess then it's being triggered before the bean is bound to JNDI.
Varsha Hardikar wrote:
How do I know if the bean is deployed first before the lookup is done?
The logs that you see on the console will show you the jndi bindings too. So ideally, you should see the beans being bound first before the servlet init() tries to lookup. Can you post the entire logs that you see on the console (not the server.log)
-
7. Re: JNDI EJB lookup in jboss5.1.0 GA
varsha7 Nov 23, 2010 12:45 PM (in response to jaikiran)This is what I see in the log:-
16:40:43,605 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
ABCBean/remote - EJB3.x Default Remote Business Interface
myear/ABCBean/remote-com.mycompanyabc.interfaces.SecurityManagerRemote - EJB3.x Remote Business Interface
ABCBean/local - EJB3.x Default Local Business Interface
myear/ABCBean/local-com.mycompany.abc.interfaces.SecurityManagerLocal - EJB3.x Local Business Interface6:41:14,561 ERROR [[/myui]] Servlet /myui threw load() exception
javax.naming.NameNotFoundException: ABCBean/remote could not be found
at com.mycompany.abc.gui.servlet.MyServlet.getMyManager(MyServlet.java:120)
at com.mycompany.abc.gui.servlet.MyServlet.init(MyServlet.java:46)Looks like the bean is bound first before the servlet init() tries to lookup but I am not sure what the two lines mean and which jndi binding is picked up.
ABCBean/remote - EJB3.x Default Remote Business Interface
myear/ABCBean/remote-com.mycompany.abc.interfaces.MyRemote - EJB3.x Remote Business Interface -
8. Re: JNDI EJB lookup in jboss5.1.0 GA
jaikiran Nov 23, 2010 11:54 PM (in response to varsha7)Please post the lookup code from your servlet.
[Edit: You did post the servlet code a few posts back. The code looks OK. How do you get the "ctx" object? Other than that it looks fine]
-
9. Re: JNDI EJB lookup in jboss5.1.0 GA
varsha7 Nov 29, 2010 4:05 PM (in response to jaikiran)There was something wrong with my setup. Jaikiran, the solution you suggested works. Thank you very much for your help.
-
10. Re: JNDI EJB lookup in jboss5.1.0 GA
varsha7 Nov 30, 2010 12:47 PM (in response to varsha7)I am wondering if
import org.jboss.ejb3.annotation.LocalBinding;
import org.jboss.ejb3.annotation.RemoteBinding are backwards compatible for jboss 4.2.3-GA.. I tried the same code which was working on jboss 5 on jboss 4.2.3.GA and get a NameNotFoundException when doing the lookup on the ejb. -
11. Re: JNDI EJB lookup in jboss5.1.0 GA
jaikiran Dec 1, 2010 1:12 AM (in response to varsha7)User User11 wrote:
I am wondering if
import org.jboss.ejb3.annotation.LocalBinding;
import org.jboss.ejb3.annotation.RemoteBinding are backwards compatible for jboss 4.2.3-GA..No they are not. The annotation package changed from AS4 to AS5. For AS4, the annotations reside in a different package. See this for AS4 http://docs.jboss.org/ejb3/docs/tutorial/jndibinding/jndi.html