• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoInitialContextException In EJB3.0with JBOSS

 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am working in ejb3.0 and Jboss4.X .
I ahve creatde and deployes a stateful session bean in Jboss Server.
Below is my client code to access the delpoyed Session Bean:


But I am getting an error :

Exception in thread "main" 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 org.jboss.tutorial.entity.client.Client.main(Client.java:40)


At my JMX-console I can see the entry like,under
Global JNDI Namespace:


Please let me know where I am missing the thing
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's what you have to do
 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pai,the solution there is given as:
Place a jndi.properties file in your classpath.
So i did already,but still getting the same exception.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How exactly did you place it in the classpath?
 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing is that the jndi.properties file is at my root folder of project.
I have put placed that file inside jre/lib ,as its took that properties file from there
Could you please suggest me the steps to put the jndi.properties file in the classpath
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What command do you use to run the client class. That will help us to provide you more inputs on how to add that file to the classpath.
 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running the client code(standalone application)using eclipse, by right clicking on that java file.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Move the jndi.properties file to the source folder. For example, if your Java source files are located in "src", move it to "src". If they are located in "src/main/java", move it to "src/main/java". The other option is to place it in a separate resource folder and make that folder a source folder in Eclipse. For example, my properties files are located at "src/main/resources".
 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did the same ,put my jndi.properties inside my src folder where my other java files resides,but it is still not reading that file.
 
VP Krish
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Was wondering if you managed to resolve your issue. I'm still baffled by this.

Vp
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic