wood burning stoves 2.0*
The moose likes BEA/Weblogic and the fly likes Error creating Initial Context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Error creating Initial Context" Watch "Error creating Initial Context" New topic
Author

Error creating Initial Context

Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
Hi,
I am a J2EE newbie.I am running Weblogic 7.0. My Client code is like -



Hashtable env = new Hashtable(5);
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://myServer:7001");

Context ctx = new InitialContext(env);



However, I get an error

javax.naming.ServiceUnavailableException [Root exception is java.net.UnknownHostException: myServer]
at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:41)
at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.jav
a:636)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.jav
a:333)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.jav
a:222)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:149)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at day04.Client.main(Client.java:32)
Caused by: java.net.UnknownHostException: myServer
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
at java.net.InetAddress.getAddressFromNameService(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at weblogic.rjvm.RJVMFinder.getDnsEntries(RJVMFinder.java:321)
at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:162)
at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:263)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.jav
a:324)
... 7 more



Can anyone help, please? Am pretty desperate. Thanks in advance.
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
The exception is clear "java.net.UnknownHostException:". myserver is not valid IP address. Check the IP address/server name and try with that. Try to ping the myserver first.
Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
Thanks Purushothaman

Thank you so much for your help.
I figured that my env settings were not the same as the one in my config.xml file. Then it worked without the naming exception. My code is -

Hashtable env = new Hashtable(5);
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:9093");

Context ctx = new InitialContext(env);

String name = "dami";
String email = "dami@hotmail.com";
ctx.bind(name,email);
String s =(String)ctx.lookup("dami");
System.out.println(s);

However, nothing is printed in the output, the system just seems to stay still.

I would really, really appreciate your help.

Thanks
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
The same code worked when I tested with WL 9.2. I didn't face any issue. You can do some check on the JNDI tree in admin console under the server link. The binded object must be seen there. There are other ways to test like calling other API's in InitialContext. Take a look at this tutorial it will be handy.
http://java.sun.com/products/jndi/tutorial/basics/naming/index.html
Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
Hi,
Thanks SO much for your hepl. In the event, I was looking around on the net, and read somewhere that there might be a certifcate problem. Since I am using an evaluation version of WebLogic, that mightbe the problem. So have decided to give up on WL, am switching to JBoss. Thanks sooooooo much.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error creating Initial Context
 
Similar Threads
Exception accessing Local EJB
configuring service provider for jndi lookup
JNDI issue: "domain was null"
com/ibm/CORBA/iiop/ORB - Help
Getting CommunicationException