File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes unable to get Naming Context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "unable to get Naming Context " Watch "unable to get Naming Context " New topic

unable to get Naming Context

Mohan Venkat

Joined: Jun 21, 2004
Posts: 3
Hi there,
I am new to Jboss-3.2.1 and trying to test a small stateless session bean. I hv created a war file with ejb-jar.xml,jboss.xml,web.xml,jboss-web.xml.

In a simple jsp file i created the naming context thru this:

Properties props = new Properties();

props.setProperty ("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");

Context ctx = new InitialContext(props);

when i am looking up with ctx.lookup() it says
Name not bound exception.

help needed urgently
Bob De Niro

Joined: Jun 22, 2004
Posts: 1
Here is the method that i always use with JBoss 3.2.3 :

public static Context getInitialContext() throws Exception {

Properties prop = new Properties();

prop.put(Context.PROVIDER_URL, "jnp://localhost:1099");prop.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces");

return new InitialContext(prop);
Amit Jaipaul

Joined: Jul 17, 2003
Posts: 16
Try using following code for getting initial context:

public static Context getInitialContext()
throws javax.naming.NamingException
context initialized by file
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "jboss.naming rg.jnp.interfaces");
p.put(Context.PROVIDER_URL, "localhost:1099");
return new javax.naming.InitialContext(p);
Mohan Venkat

Joined: Jun 21, 2004
Posts: 3
Thanx for the info.

I cud resolve this by using:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put("java.naming.factory.url.pkgs", "org.jboss.naming rg.jnp.interfaces");
Context ctx = new InitialContext(env);

and by adding jbossall-client.jar,jboss-client.jar,jboss-common-client.jar and jnet.jar to my classpath and it is working now.

I agree. Here's the link:
subject: unable to get Naming Context
It's not a secret anymore!