Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The meaning of NoInitialContextException error

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.

like image 306
Attilah Avatar asked Oct 06 '09 12:10

Attilah


1 Answers

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.

like image 163
skaffman Avatar answered Sep 19 '22 00:09

skaffman