Issue
After moving from Java8 to Java11, I'm getting the error "package com.sun.jndi.ldap is not visible". But I need this package for the Class LdapCtxFactory. Is the package moved or should I use another Class for my Ldap-Connection?
Best regards
Solution
Since your only use of the class LdapCtxFactory
is a configuration setup as
env.put(Context.INITIAL_CONTEXT_FACTORY, LdapCtxFactory.class.getName());
you can remove the dependency to the class by replacing LdapCtxFactory.class.getName()
with the qualified name "com.sun.jndi.ldap.LdapCtxFactory"
, i.e.
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
Answered By - Holger
Answer Checked By - Terry (JavaFixing Volunteer)