• 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

JNDI lookup fails

 
Ranch Hand
Posts: 85
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please help me with this one...
I am using WebSphere Studio Application Developer 5.1 and i have deplyoed an ear file on the test server. I have created the Connection factory and queue. I am trying to do a jndi lookup for the connection factory by using the following code :

Hashtable envEntry = new Hashtable();
envEntry.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");

Context initial = new InitialContext(envEntry);
Object object = initial.lookup("jms/MyconnFact");

This is giveing me a error like this :

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

Can anyone pls tell me why this is happening and how do I correct it?

Thanks,
Janhavi.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://java.sun.com/products/jms/tutorial/jms_tutorial_faq.html#NoInitContext

If you have installed a new version of the J2SE SDK without first removing the previous one, this problem and others can result.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where are you encountering this error? Is this in a Servlet class, an EJB class where? Give us more information and we might be able to help you.

Kyle
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

You can try to use the Universal test client within WSAD to browse the available JNDI names.
You can point this client to your dev server so you could check if the resource you need is indeed register there.

Hope it helps
/Shraga.
 
Janhavi Namshikar
Ranch Hand
Posts: 85
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kyle Brown:
Where are you encountering this error? Is this in a Servlet class, an EJB class where? Give us more information and we might be able to help you.



I am getting this problem in a EJB, that I have create as the Message sender.
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, if this is running inside the EJB Container (inside the WebSphere Test Server) then you don't need to specify any parameters at all for the InitialContext. Just using:



should work just fine. This is explained in Chapter 22 of my WebSphere book.

If this will not work for you, then my guess is that you may have included one or more of the WebSphere JAR files (for instance j2ee.jar) either inside your EAR file. Duplicate copies of WebSphere classes can sometimes cause this kind of problem.

Kyle
 
Janhavi Namshikar
Ranch Hand
Posts: 85
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kyle... the code works now

the problem was due to the duplicate j2ee.jar, when I removed one of the j2ee.jar, the code start to work OK.


Janhavi.
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic