powered by Jive Software

Smack fails under JDK 11 because com.sun.jndi.dns.DnsContextFactory is not inaccessible


#1

commenting out
env.put(“java.naming.factory.initial”, “com.sun.jndi.dns.DnsContextFactory”);
below fixes the issue

public class JavaxResolver extends DNSResolver implements SmackInitializer {

    private static JavaxResolver instance;
    private static DirContext dirContext;

    static {
        try {
            Hashtable<String, String> env = new Hashtable<>();
            env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
            dirContext = new InitialDirContext(env);
        } catch (Exception e) {
            // Ignore.
        }

        // Try to set this DNS resolver as primary one
        setup();
    }

#2

Thanks for reporting this. :+1:

Just do double check: Fixes the issue as in “makes smack compile with JDK 11” or “makes smack compile under JDK 11 and still allows for successful DNS lookups”?


#3

It makes it run under 11. I did not try to compile smack I just made a copy of the class, removed this line and put it before smack jars in my class path. The class mentioned in the removed line is no longer accessible at run time as it is not exported by it’s module in jdk 11


#4

Created SMACK-856.