Failure to Instantiate DnsContextFactory
shelleyb Aug 4, 2011 6:11 PMWhen attempting to create a new InitialDirContext using the com.sun.jndi.dns.DnsContextFactory, the following exception occurs:
Caused by: javax.naming.NamingException: Failed instantiate InitialContextFactory com.sun.jndi.dns.DnsContextFactory from classloader ModuleClassLoader for Module "deployment.test-case.ear.test-web.war:main" from Service Module Loader at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:58) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:664) [:1.6.0_26] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) [:1.6.0_26] at javax.naming.InitialContext.init(InitialContext.java:223) [:1.6.0_26] at javax.naming.InitialContext.(InitialContext.java:197) [:1.6.0_26] at javax.naming.directory.InitialDirContext.(InitialDirContext.java:82) [:1.6.0_26] at com.test.messaging.internal.resource.dns.DnsClientImpl.querySrv(DnsClientImpl.java:328) [dns-lookup-jar.jar:] ... 16:36:36,000 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-5) Error listenerStart 16:36:36,013 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-5) Context [/test] startup failed due to previous errors 16:36:36,023 INFO [org.jboss.web] (MSC service thread 1-5) registering web context: /test
Here is my relevant code snippet:
Hashtable env = new Hashtable(); env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); env.put("java.naming.authoritative", "false"); env.put("com.sun.jndi.dns.recursion", "true"); env.put("com.sun.jndi.dns.timeout.initial", timeoutProp); env.put("com.sun.jndi.dns.timeout.retries", "1"); env.put("java.naming.provider.url", providerProp); DirContext ctx = new InitialDirContext(env);
I found this thread which seemed very similar to the problem that I am running into, but setting the "jboss.modules.system.pkgs" property to "com.sun.jndi.dns" had no effect.
I'm running JBoss AS 7.0.0.Final, using the 1.6.0_26 JRE.
Any suggestions on how to resolve this problem would be greatly appreciated.