• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB JNDI Absolute/Relative Path Problem  RSS feed

 
David Harrigan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
First time poster, long time lucker....
Using the Sun J2EE RI, I created an extremely simple session bean that just returned a string for displaying to the console. I created a little app to be run from the command line that did a lookup on the bean and invoked its remote method. Can someone explain the following:-
Why:-


works in that it finds the bean, and,

fails in that I get a NameNotFoundException.
Hence, a relative path works, and an absolute path fails. I was under the assumption that everything was held in the java:comp/env JNDI hierarchy (at least when it comes to J2EE stuff).
I thought that perhaps it was a problem because my client app wasn't running as part of the J2EE app, therefore didn't have access to the absolute path, so I got my simple session bean to do a lookup on another simple session bean, so everything was running within the same container, but same problem, in that absolute path lookup fails, relative path succeeds.
Would anyone have any pointers as what is going on???
TIA.
-=david=-
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hence, a relative path works, and an absolute path fails. I was under the assumption that everything was held in the java:comp/env JNDI hierarchy (at least when it comes to J2EE stuff).

Actually, it's the absolute path that's working...
"ejb/MyBean" is an absolute, real JNDI name while "java:comp/env/ejb/MyBean" is a logical or private JNDI name. In order to be able to use a logical JNDI name, you need to map it into a real JNDI name using a reference in the deployment descriptors (ejb-jar.xml and the vendor-specific one).
 
David Harrigan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm confused (happens a lot, so don't worry :-) According to the JNDI tutorial on the Sun website, the form: java:comp/env/ejb/myBean is called an absolute URL.
http://java.sun.com/products/jndi/tutorial/beyond/url/initctx.html
i.e., The closest thing to an absolute name in the JNDI is a URL string.
and java:comp/env/ejb/myBean is an URL string (since it contains the locator java
Are you saying that I need to code in:-
java:comp/env/ejb/myBean as the JNDI reference, and not ejb/myBean as put forward in the J2EE tutorial?
Help! /me confused!
-=david=-
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you're referring to a generic JNDI tutorial (and to qualify as a URL scheme part, the string would've needed to start with "java://", not just "java:").
Anyway, you should stick to an Enterprise JavaBeans tutorial (or a book, such as "Mastering EJB" which is available in PDF from TheServerSide.com).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!