File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI question in JBoss environment

 
Michael Valentino
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Daniel Rhoades
Ranch Hand
Posts: 186
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic