• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

JNDI lookup for JMS...URGENT!

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using J2EE SDK1.4 to work some basic examples on JMS.
In all examples that i see on sun tutorials, the syntax they use for lookup is as below:
jndiContext =new InitialContext();
There is no hard coding for the Initial Context Factory.
However when i execute the examples it gives me an exception as below:
---------------------------------------------------------------------------
D:\examples\JMS>java -Djms.properties=%J2EE_HOME%\config\jms_client.properties
roperties SimpleQueueReceiver MyQueue
Queue name is MyQueue
JNDI API lookup failed: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
----------------------------------------------------------------------------
which i infer means that the initial context was not created.
How do i go abt with this?
Where is the properties file located in the J2EE SDK?
Also if i need to hard code it how can i go about it?
Also if i need to do lookup on some other container like eg weblogic 8.1 or websphere 5.0 where is the properties file located? How to go abt it?
Sorry, i know thats toooooo may questions. But hope someone can help. This is VERY URGENT!!!
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apparently your project needs to read a file called jndi.properties in order to access your server. Now depending on the server, different contexts are developed.
If you are using JBoss, a jndi.properties file should be saved in your classes folder and it should look like this:
Hashtable env = new Hashtable();
env.put (Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"jnp://localhost:1099");
 
meenakshi ashokkumar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried that with the following code for j2ee ri
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtx");
p.put(Context.PROVIDER_URL,"iiop://localhost:1050");
jndiContext =new InitialContext(p);
But it results in the following error!
-------------------------------------------------------
D:\examples\JMS>java SimpleQueueReceiver MyQueue
Queue name is MyQueue
Could not create JNDI API
context:javax.naming.NoInitialContextException: Cannot instantiate class
: com.sun.jndi.cosnaming.CNCtx [Root exception is java.lang.IllegalAccessExcepti
on: Class javax.naming.spi.NamingManager can not access a member of class com.su
n.jndi.cosnaming.CNCtx with modifiers "private"]
-----------------------------------------------------------
If there is a mistake in the Initial context factory name or url name can someone help??
 
Dm Laf
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably need to include in your project's classpath all the jars which are located in your server's libs directory
 
reply
    Bookmark Topic Watch Topic
  • New Topic