Getting NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file in JBoss EAP
Issue
-
I have a standalone java client, which looks up EJB deployed to EAP 6 using it's Remote interface, and the java:global namespace. However when I run the client, I get the exception for the article title.
-
On EAP 5 I have an EJB client running in JBoss EAP, it creates an InitialContext passing in properties such that it can look up an EJB running in a remote server as such:
private Context context = null;
public void callRemoteEJB()
{
...
if(context == null)
{
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
properties.put("jnp.socket.Factory", "org.jnp.interfaces.TimedSocketFactory");
properties.setProperty("java.naming.provider.url", "jnp://" + remoteHost + :1099");
context = new InitialContext(properties);
}
// look up the remote ejb and call methods on it
try
{
context.close();
} catch(Exception e)
{
// eat the exception
}
...
}
The first time the client looks up the ejb it succeeds and is able to call it, however the next time the client tries to lookup the remote EJB and invoke it, it fails with the exception for the article title.
Environment
- JBoss Enterprise Application Platform (EAP)
- 5.x
- 4.x
- 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
