aspose file tools*
The moose likes JBoss/WildFly and the fly likes NoInitialContextException In EJB3.0with JBOSS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "NoInitialContextException In EJB3.0with JBOSS" Watch "NoInitialContextException In EJB3.0with JBOSS" New topic
Author

NoInitialContextException In EJB3.0with JBOSS

Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
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

Joined: Jul 20, 2005
Posts: 10263
    
168

Here's what you have to do


[My Blog] [JavaRanch Journal]
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
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

Joined: Jul 20, 2005
Posts: 10263
    
168

How exactly did you place it in the classpath?
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
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

Joined: Jul 20, 2005
Posts: 10263
    
168

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

Joined: May 30, 2007
Posts: 189
I am running the client code(standalone application)using eclipse, by right clicking on that java file.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

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".


JBoss In Action
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
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

Joined: Nov 09, 2008
Posts: 1
Hi,

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

Vp
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: NoInitialContextException In EJB3.0with JBOSS