• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Using SessionBeans from POJO within the ear...

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which application server do you use?
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic