• Post Reply Bookmark Topic Watch Topic
  • New Topic

NoInitialContextException

 
Richard Robbins
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating a JMS application, and I keep getting a NoInitialContextException whenever I execute:
Context ctx = new InitialContext();
QueueConnectionFactory queueConnectionFactory =
(QueueConnectionFactory)ctx.lookup("QueueConnectionFactory");
Does anyone know what might be causing this? Here is the complete exception message:
Error: 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
Thanks for your help.
Richard
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Richard,
U have to specify the env variables i.e. the InitialContext Factory and the Provider URL (host) for the same. If u go thru any coded examples u can get the same and then change it as per u'r need.
HTH
Sahil
 
Gregg Wachter
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the same problem when testing out a jndi sample prgram this week. The funny thing is I didn't get this exception on my Win2000 system hacing a jndi.properties file in the same directory when I started the test program.
However, when I moved this same sample code to my unix system at work I got the same exception you mentioned. I verified that the jndi.properties file was still aavailable for reading (-Dproperties.path=./properties) but on unix the jndi.properties was being ignored. I eventually just had to create a new Hashtable in my program and put the jndi properties in it to get the program to work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!