File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Injecting EJB into servlet

 
Alejandro Dominguez
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,

my ear file contains the ejb.jar and webapp.war files; in my webapp I have a servlet into which I'd like to inject an EJB reference.

From the servlet, the following code works perfectly:



However, trying to achieve the same by injection, results in a NullPointerException as soon as I try to run one of the bean's methods



Am I missing something here?

Regards
 
Lave Kulshreshtha
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please provide some more details?

-Lave
 
Vesa Tanhua-Tyrkk´┐Ż
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think that injection is not possible in web tier.
So jndi lookup is the only possible option.
 
Edvins Reisons
Ranch Hand
Posts: 364
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alejandro,

you may want to check your server against the list of Java EE 5 compatible servers here
 
PK Ghosh
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

I know JBoss 4.0.4 does not support EJB injection into servlet container. It suppose to fix on 5.0
 
Alejandro Dominguez
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm Using JBoss 4.2.2 GA, so maybe that's the problem... oh well, I'll stick to jndi lookup meanwhile.

Thanks!
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, JBoss4.2.2 does not support EJB injection in servlets.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic