Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error callling remote EJB with JNDI name?

843829Apr 8 2002 — edited Jun 10 2005
Basically, I'm trying to talk to an EJB sitting on a remote box through a client class which I have written. When I try to do a JNDI lookup on the EJB I get a "Could not get InitialContext" error.

My code is as follows:

// Populate URL
String url = "IIOP://" + "192.168.1.2" + ":" + "900" + "/";
p.put(javax.naming.Context.PROVIDER_URL, url);
System.out.println("Using provider URL of: " + url);
p.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");

initialContext = new InitialContext(p);
String jndiName = BuildSystemProfile.class.getName().replace('.', '/');
Object o = initialContext.lookup(jndiName);
System.out.println("jndiName = " + jndiName);

BuildSystemProfileHome home = (BuildSystemProfileHome) PortableRemoteObject.narrow(o, BuildSystemProfileHome.class);
BuildSystemProfile bsf = home.create();
String msg = bsf.testMsg("You say hello");

The error I get is as follows:
===============================
// These are my debug code - you can see the jndi name I am using
Using provider URL of: IIOP://192.168.1.2:900/
jndiName = tdw/ejb/BuildSystemProfile

Could not get InitialContext!
javax.naming.NameNotFoundException: tdw/ejb/BuildSystemProfile
java.lang.Throwable(java.lang.String)
java.lang.Exception(java.lang.String)
javax.naming.NamingException(java.lang.String)
javax.naming.NameNotFoundException(java.lang.String)
java.lang.Object com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(org.omg.CosNaming.NameComponent [])
java.lang.Object com.ibm.ejs.ns.jndi.CNContextImpl.lookup(java.lang.String)
java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)
void tdw.ejb.TestBuildSystemProfile.main(java.lang.String [])

Assumptions:
============
- The IP address in the URL is correct
- I am using Websphere 4.0.
- The EJB has been deployed as a EJB 1.1 jar
- The EJB is running within the WebSphere container
- The EJB has a JDNI name within the Websphere Admin console of tdw/ejb/builsystemprofile
- The EJB name is BuildSystemProfile

Questions:
==========
- Is the JNDI naming correct? I am using the exact same name which is in the Websphere Admin console
- What port number should I be using? Can't seem to configure/view this through Webspere.

Do you have any suggestions? Am I doing something stupid?

Thanks in advance.
Regards
Michael
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 8 2005
Added on Apr 8 2002
11 comments
624 views