• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to get Naming Context

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic