• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error creating Initial Context

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic