This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to get Naming Context

 
Mohan Venkat
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Bob De Niro
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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);
}
 
Amit Jaipaul
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic