Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Local Home JNDI Lookup Failure

 
Dhanesh Kothari
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
My java client program is unable to do a lookup for Local Home Interface.
Error Message:
>> javax.naming.NameNotFoundException: No object bound for
>> java:comp/env/ejb/Movie
>> at com.sun.enterprise.naming.java.javaURLContext.lookup
>> javaURLContext.java:116)at javax.naming.InitialContext.lookup
>> (InitialContext.java:347)
>> at MoviesClient.go(MoviesClient.java:40)
>> at MoviesClient.main(MoviesClient.java:31)
Client Program:
>> Context ic =new InitialContext();
>> Object o = ic.lookup("java:comp/env/ejb/Movie");
Server XML (sun-j2ee-ri.xml):
<ejb>
<ejb-name>MovieBean</ejb-name>
<jndi-name>Movie</jndi-name>
:
:
</ejb>
As the message shows Naming service could not lookup the name.
I'm trying to run an example on J2EE RI 1.3
Also note that I'm able to do a lookup for Remote Home without any problems.
The only difference is for Remote Lookup I have used the JNDI name directly.
>> Context ic =new InitialContext();
>> Object o = ic.lookup("Customer");
I have also tried same approach for the Local Home Interface. But then it gives::
javax.naming.NameNotFoundException: Movie not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.
java:174)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.ja
va:146)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialCont
extProviderImpl.java:63)
at org.omg.stub.com.sun.enterprise.naming._SerialContextProviderImpl_Tie
._invoke(Unknown Source)
at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegat
e.java:355)
at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:255)
at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProces
sor.java:84)
at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadP
ool.java:99)
During deployment, server also shows the message :
Binding name:`java:comp/env/ejb/Movie`
Please let me know what do I need to do to resolve this problem.
Thanks and Regards
 
Balasubramaniam K.R
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just give the JNDI name "Movie" and try it will work.
What you are trying is to find other beans within your bean through ejb ref in your beans own environment.
Cheers,
Balu
 
Dhanesh Kothari
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that as well. But still I'm getting Naming Exception.
Please note that the client is a standalone java program with a main method.
I saw some posts on various sites with the same problem. But none of them has provided any solution to this.
Let me know if any more information is needed to help me with resolving this problem.
Thanks
-Dhanesh
 
Dhanesh Kothari
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ther,
As I have mentioned above in my original post towards the end, when I do a lookup using "Movie", I get:
javax.naming.NameNotFoundException: Movie not found.
Let me know if any more information is needed to help me solve this problem.
Thanks and Regards,
-Dhanesh
 
Matt Gaunt
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
You mention that your applicaiton is a stand alone client with a main method. Surely that will be your problem. If your application is standalone, then do you mean it is running in a seperate JVM to that of the server that the local EJB is running on?
If that is the case, then when you are doing a lookup of Movie, then you won't be able to see it cause the server will not be allowing it to be seen to the 'outside' world. Hence the reason it is local. It is local to the server and the server's JVM. Only applications running on the server will be able to find the Movie EJB. Stand alone applications will only be able to find remote ejbs running on the server, as they are the only ones the server will allow to be seen.
Hope this helps
Best Regards
Matt Gaunt
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt's absolutely right on that one... your stand-alone client cannot look up the local interface of the bean. Local interfaces are meant for one bean in an application to lookup a reference to another bean in the same application (and both must be running the same JVM). A local interface reference is a *real* Java reference, not a remote RMI stub.
If you want, you can deploy the Movie bean with BOTH types of interfaces -- a remote and a local inteface, if you want to, say, test it from a stand-alone client. Or better yet -- build a Session bean that talks locally to the Movie bean, then have your stand-alone client talk to the Session bean, and have the Session bean work with the Movie bean.
Your lookup code is correct for a local bean, though, because remember that "java:comp/env" is what a bean uses, within its own methods, when it needs to look something up in JNDI. The "java:comp/env" is the bean's own "special place" the server creates when the bean is deployed, so if you use that Session bean-to-Movie bean scenario, then the Session bean's lookup code would be using the "java:comp/env/ejb/Movie" as its lookup, and you can say in your DD that the Session bean will have an ejb reference to the Movie bean.
Cheers,
Kathy
 
Dhanesh Kothari
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I figured that out over the weekend. But was not able to put my comments.
1> Local EJB must be access by the resources within the same JVM (Servlet, JSP, another EJB etc.)
2> Any resource which refers to this Local EJB, must give appropriate reference during deployment.
Thanks
-Dhanesh
 
Harvey Chan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed that seems looking up Local Object using
WebSphere 5 is like this...
xxx.lookup("local:/ejb/xxxx")
Can anyone tell me whether this is VENDOR specific???
 
Arvindu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it very specific for
Websphere 5.0 and above
not needed in this way for weblogic
 
Randy Schnier
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Harvey Chan:
I noticed that seems looking up Local Object using
WebSphere 5 is like this...

xxx.lookup("local:/ejb/xxxx")

Can anyone tell me whether this is VENDOR specific???



Not only is it vendor-specific, it's not supposed to be used at all by application code. It's an internal implementation aspect of WAS (used only by other parts of WAS itself) and may change or be eliminated at any time.

The supported, vendor-independent way to do local EJB lookups is to create an ejb-local-ref and ejb-link in the calling component, point the ejb-link at the target EJB, and look up the local home in the java:comp/env namespace at whatever name was assigned to the ejb-local-ref. If you do it this way, it will work correctly on any J2EE-compliant appserver.

Randy Schnier
IBM Websphere
 
Ramya Iyer
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting NameNotFoundException...not able to retrieve the local interface from OrderBean.

Context context = new InitialContext();
Object o = context.lookup("java:comp/env/ejb/Shipment");
ShipmentLocalHome home = (ShipmentLocalHome) o;
ShipmentLocal local = home.findByPrimaryKey(new ShipmentKey(shipment_key));
setShipment(local);

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic