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

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();
    }

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”?

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

1 Like

Created SMACK-856.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.