Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using SessionBeans from POJO within the ear...  RSS feed

 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys/Gals,

I have a project that is really starting to get to me. I wanted to run this by you to see if you had any ideas. Currently I have 3 projects (Using Maven) One EAR project for the completed build and deployment, one EJB project which contains the Beans and POJO's for the business logic, and WEB project which uses JSF amount other frameworks. The problem I am having I would think would be simply however its driving me nuts. From withing my EJB project I have a standard POJO that I want to access a stateless session bean. I have attempted injection but found out that this method does not work from within the POJO. My next step was to use JNDI lookup however I cannot get it to find the object. I'm going to post the examples below to see if somebody has any ideas. I'm getting frustrated and figured somebody here could open my eyes. Also you should know that accessing these beans from the web side via Servlets and Managed Beans works 100% with no problems.


** Stateless SessionBean



*** POJO using injection (Does not work)


*** POJO using JNDI


OR



Both of these JNDI examples return back NameNotFoundException. Can anybody shed some light as to what is going on?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have attempted injection but found out that this method does not work from within the POJO.

This is correct. You cannot use injection within a POJO.

Did you look in your server's console to see that it is bound to the JNDI name you are expecting.
 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is I cannot determine the name it is bound to. I've attemped using mappedName name and others in the annotation however when doing the lookup we can never seem to find the correct bound name? Any tips?
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which application server do you use?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!