This content has been marked as final.
Show 1 reply
-
1. Re: unable to lookup an EJB from a JavaBean
newtonm Jan 5, 2005 10:42 AM (in response to hubaghdadi)Hi,
The javax.naming.NameNotFoundException is being thrown because you have bound the EJB into the global namespace with the name 'ejb/Liga' but you are looking for it in the ENC namespace (java:comp/env).
When you changed the jndi-name to Liga and used the following code, you correctly lookup the bean using JNDI:Object obj = ic.lookup("Liga");
However as you are no longer using the ENC namespace your web application isn't as portable as it could be. If the EJB is bound to a different name, like it was before 'ejb/Liga', then you will have to change the lookup string in your source code to 'ejb/Liga' and recompile it in order for it to work.
Ideally what you should do is add an <ejb-ref> or <ejb-local-ref> element to your web.xml file and then add the corresponding <ejb-ref> or <ejb-local-ref> element to your jboss-web.xml file. These tags map your ENC name to the global name which the EJB is really bound to. You can then use:Object obj = ic.lookup("java:comp/env/ejb/Liga");
hopefully this is enough information to get you on the right track.
Mark