Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNDI question in JBoss environment

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an EJB deployed on JBoss 4.0.2 application server. I wrote a stand alone java client to access the bean, but I'm getting unexpected behavior.

If i try to lookup the bean this way:


everything works fine. However, if I try to lookup the bean in this way:


I get the following error and stack trace:


Any ideas on why this may be happening?
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This works for me in JBoss:

<CODE>
InitialContext iniCtx = new InitialContext();
Context ejbCtx = (Context) iniCtx.lookup("java:comp/env/ejb");
Object obj = ejbCtx.lookup("Fortune");
</CODE>
 
Michael Valentino
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A lookup such as the one you've posted works for me as well, but only when the client to the EJB is running in the same container as the EJB. Otherwise I get a "comp not bound" message in an exception. I'm not a JNDI guru, but I'm guessing it has to do with the JNDI namespaces - the EJB running on one instance of the JVM is in one JNDI namespace, while the client running in another instance of the JVM is in a different namespace. Doing a global lookup ( ctx.lookup("/ejb/myEJB"); ) works while doing a specific ( ctx.lookup("java:comp/env/ejb/myEJB") ) will not due to the difference in namespaces. Is this correct? If not, what am I misunderstanding?

Thank you for your help.
 
My pie came with a little toothpic holding up this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic