wood burning stoves*
The moose likes EJB and other Java EE Technologies and the fly likes How do I get an instance of a Stateless Session EJB deployed alone in Glassfish, from a Servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How do I get an instance of a Stateless Session EJB deployed alone in Glassfish, from a Servlet?" Watch "How do I get an instance of a Stateless Session EJB deployed alone in Glassfish, from a Servlet?" New topic
Author

How do I get an instance of a Stateless Session EJB deployed alone in Glassfish, from a Servlet?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
Hi,

I'm using Glassfish (Sun Java System Application Server 9.1_01 (build b09d-fcs)).
I've deployed an EJB (Stateless Session Bean) in "Applications>EJB Modules" in Glassfish.
I want to access this EJB from a Servlet, which is deployed in a war file.

The following errors are rising:
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref
javax.naming.NameNotFoundException:

My code:

Servlet:



EJB:



sun-ejb-jar.xml:



in web.xml I put:


What should I do to make this work?


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Jayr Motta
Ranch Hand

Joined: Jul 30, 2010
Posts: 110

I'm really surprised, a guy with this amount of certifications in the title not being capable of deploy / use an EJB?

First of all you should not use a reference to your EJB class directly, instead use your LDAPLocal within the servlet. Try it and tell us if it works.


Feel free to ask me anything!
www.BlackBeltFactory.com/ui#!/ref=jmotta, SCJP 6, OCWCD JEE5, OCE EJB JEE6
Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
Jayr Motta wrote:I'm really surprised, a guy with this amount of certifications in the title not being capable of deploy / use an EJB?

First of all you should not use a reference to your EJB class directly, instead use your LDAPLocal within the servlet. Try it and tell us if it works.


Yes, but I like testing the knowledge of my Javaranch friends

I changed to LDAPLocal, but it is not even deploying (war file)...
Jayr Motta
Ranch Hand

Joined: Jul 30, 2010
Posts: 110

If it's not even deploying then your problem is bigger than just referring the right interface while injecting your EJB. Figure out why are you having problem with this and then you may try to inject as I told you.

Do you have a .ear with an application.xml? You're packaging your EJB's in this war?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I get an instance of a Stateless Session EJB deployed alone in Glassfish, from a Servlet?