File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EJB, JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "EJB, JNDI" Watch "EJB, JNDI" New topic
Author

EJB, JNDI

Mamadou Touré
Ranch Hand

Joined: Dec 27, 2007
Posts: 189
Hi,

Hi ,

I'm new in EJB, I creaed an EJB3 module that I package and deployed under Glassfish, but when I try to call it through a JSP servlet (by using the DI with @EJB annotation), I got an error, so should I declare something in the JNDI.

HEre is the error
bean.HelloWorldBean@null@bean.HelloWorldBean@Session@null into class servlet.ServletClient at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387) at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206) at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:117) at com.sun.web.server.J2EEInstanceListener.handleBeforeEvent(J2EEInstanceListener.java:259) ... 31 more Caused by: javax.naming.NameNotFoundException: bean.HelloWorldBean#bean.HelloWorldBean not found at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216) at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)


SCJP 5 (76%)
SCWCD 5 (86%)
SCBCD 5(70%)
--------------------
"The greatest glory in living lies not in never falling, but in raising every time we fall.".. Nelson Mandela
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
HEre is the error
bean.HelloWorldBean@null@bean.HelloWorldBean@Session@null into class servlet.ServletClient at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387) at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206) at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:117) at com.sun.web.server.J2EEInstanceListener.handleBeforeEvent(J2EEInstanceListener.java:259) ... 31 more Caused by: javax.naming.NameNotFoundException: bean.HelloWorldBean#bean.HelloWorldBean not found at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216) at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)


-One reason could be that you are using name param in @Stateless tag (& name is different from class name) but you are using class name for @EJB (it's just a wild guess).
I think if you share the code (please used code tag), it would be helpful to get the reason for error message.

thanks.

Mamadou Touré
Ranch Hand

Joined: Dec 27, 2007
Posts: 189
Hi folks,
Below are the error I got, my EJB code and my servlet Code.

what do I forget ?
État HTTP 500 -

--------------------------------------------------------------------------------

type Rapport d'exception

Message

DescriptionLe serveur a rencontré une erreur interne () qui l'a empêché de remplir cette requête.

Exception

javax.servlet.ServletException: PWC1391 : Servlet.init() pour le servlet HelloWorldServlet a émis une exception.
Cause racine

java.lang.RuntimeException: WEB5002 : Exception dans handleBeforeEvent.
Cause racine

com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref webpackage.HelloWorldServlet/hwb@jndi: beanpackage.HelloWorldBean@null@beanpackage.HelloWorldBean@Session@null into class webpackage.HelloWorldServlet
Cause racine

javax.naming.NameNotFoundException: beanpackage.HelloWorldBean#beanpackage.HelloWorldBean not found
note Les suivis de pile complets de l'exception et de ses causes principales sont disponibles dans les journaux Sun GlassFish Enterprise Server v2.1.


and here is the Code for my bean:


Here is my servlet that call my EJB
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
Removed the technically wrong reply.
DJ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB, JNDI
 
Similar Threads
NamingException !??
EJB access from within a EJB using @EJB is failing in Sun Application Server
Help needed to deploy HelloWorld EJB
failed jndi datasource lookup for jdbc/__default on Glassfish
deployment descriptor (ejb-jar.xml) problem