aspose file tools*
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
Author

unable to get Naming Context

Mohan Venkat
Greenhorn

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");

props.setProperty("java.naming.provider.url","jnp://localhost:1099");
Context ctx = new InitialContext(props);

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

help needed urgently
regards
mohan
Bob De Niro
Greenhorn

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.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
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
Greenhorn

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 jndi.properties 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
Greenhorn

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.

regards
mohan
 
Consider Paul's rocket mass heater.
 
subject: unable to get Naming Context