[jboss-user] [JNDI and Naming] - InitialContext#lookup does not timeout

Stian Thorgersen do-not-reply at jboss.com
Mon Apr 18 04:56:19 EDT 2011

Stian Thorgersen [http://community.jboss.org/people/stianst] created the discussion

"InitialContext#lookup does not timeout"

To view the discussion, visit: http://community.jboss.org/message/600583#600583

I've got an issue where InitialContext#lookup will hang forever doing a lookup if there is a problem with the network. I appreciate this is the default settings of the TCP sockets to wait forever, so I've tried to configure the timeout using 'jnp.timeout' and 'jnp.sotimeout', but it still waits forever.

Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.put("java.naming.provider.url", "jnp://");
env.put("java.naming.factory.url.pkgs", "org.jboss.naming");
env.put("jnp.socketFactor", "org.jnp.interfaces.TimedSocketFactory");
env.put("jnp.timeout", "1000");
env.put("jnp.sotimeout", "1000");
InitialContext ctx = new InitialContext(env);
HelloWorld world = (HelloWorld) ctx.lookup("HelloWorldBean/remote");
// disconnect network here
world = (HelloWorld) ctx.lookup("HelloWorldBean/remote");

In the above example if the network is disconnected before the first lookup it times out as expected, but if the network is disconnected between the first and the second lookup it doesn't timeout at all (waited 10 min+).

Reply to this message by going to Community

Start a new discussion in JNDI and Naming at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110418/7f781aa7/attachment-0001.html 

More information about the jboss-user mailing list