I am writing a client for my EJB and when trying to execute it, I get the following exception :
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file.
I just can't understand what the problem is.
Do this:
Also add this to the libraries of the project:
C:\installs\glassfish\glassfish-4.1\glassfish\lib\gf-client.jar
adjust path accordinglyyou need to put the following name/value pairs into a Hashtable and call this contructor:
the exact values depend on your application server, this example is for jboss
Easy & configurable solution is create one jndi.properties file and put this file in classpath. jndi.properties can be created as
Just specify your naming factory & url and put this file in your classpath. JMS will fetch required info by itself and it's easily configurable in future also.
Most of the time these settings are also defined in a
jndi.properties
file. Do you have that one lying around somewhere?make sure dependencies for jetty naming and jetty plus are included (not just provided scope). This fixed it for me.
I solved the same problem by adding the following Jar libraries to my project:
from the folder :
C:\Program Files\glassfish-4.0\glassfish\lib
The links to these libraries were broken and Netbeans didn't found the right classes to use.