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.
The javax.naming
package comprises the JNDI API. Since it's just an API, rather than an implementation, you need to tell it which implementation of JNDI to use. The implementations are typically specific to the server you're trying to talk to.
To specify an implementation, you pass in a Properties
object when you construct the InitialContext
. These properties specify the implementation to use, as well as the location of the server. The default InitialContext
constructor is only useful when there are system properties present, but the properties are the same as if you passed them in manually.
As to which properties you need to set, that depends on your server. You need to hunt those settings down and plug them in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With