• Post Reply Bookmark Topic Watch Topic
  • New Topic

NoInitialContextException error

 
Prasanna Kannan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to implement JMS Queues in simple java program(Not a J2EE application).I am using the jndi.properties to define the queue names and the connection factory.

I have placed the jndi.properties file in the current directory and configured the jndi.properties entry in my classpath. But still I am facing the following exception


Error connecting to null queue...
.................... 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
.................... at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
.................... at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
.................... at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
.................... at javax.naming.InitialContext.lookup(InitialContext.java:351)
.................... at com.gtech.esc.server.engine.JMSMessageHandler$UnsoRequestQueue.run(JMSMessageHandler.java:413)

I didnt face any problem when creating the initialContext but i am facing this issue when it tries to lookup

Line No 412 & 413 in JMSMessageHandler :

initialContext = new InitialContext();
connFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory");

Could anyone please provide me a solution for this problem.

Thanks
Prasanna
 
ujjwal soni
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If you installed a new version of the J2SE SDK without first removing the previous one, this problem and others can result.

Regards,

Ujjwal B Soni
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Maybe you're not configuring your jndi properly. Whenever you do not set it correctly it can find your objects in the application server and raise such an exception.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!