Issue:

Upgrade to spring boot 2.4.5, but my spring boot application still cannot running in JDK16

Error message:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapContextSource' defined in class path resource [org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ldap.core.support.LdapContextSource]: Factory method 'ldapContextSource' threw exception; nested exception is java.lang.IllegalAccessError: class org.springframework.ldap.core.support.AbstractContextSource (in unnamed module @0xa7e666) cannot access class com.sun.jndi.ldap.LdapCtxFactory (in module java.naming) because module java.naming does not export com.sun.jndi.ldap to unnamed module @0xa7e666

Work Around

java --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED -jar mySpringBootApp.jar

Other info

Looks like spring-ldap-core 2.3.3 still not compatiable with JDK16, need be upgraded.

Comment From: philwebb

I think this a duplicate of https://github.com/spring-projects/spring-ldap/issues/543. We'll pick up 2.3.4 when it's released.

Comment From: snicoll

@fengertao the wiki has some notes on running with more recent Java versions, see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-with-Java-9-and-above

Comment From: Nonoas

Issue:

Upgrade to spring boot 2.4.5, but my spring boot application still cannot running in JDK16

Error message:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapContextSource' defined in class path resource [org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ldap.core.support.LdapContextSource]: Factory method 'ldapContextSource' threw exception; nested exception is java.lang.IllegalAccessError: class org.springframework.ldap.core.support.AbstractContextSource (in unnamed module @0xa7e666) cannot access class com.sun.jndi.ldap.LdapCtxFactory (in module java.naming) because module java.naming does not export com.sun.jndi.ldap to unnamed module @0xa7e666

Work Around

java --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED -jar mySpringBootApp.jar

Other info

Looks like spring-ldap-core 2.3.3 still not compatiable with JDK16, need be upgraded.

I have a similar problem with springboot running in jdk11

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainController': Unsatisfied dependency expressed through field 'odrService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OrderServiceImpl' defined in file [D:\MyCode\IDEA\CRM-v200213\target\classes\indi\nonoas\crm\service\impl\OrderServiceImpl.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class indi.nonoas.crm.service.impl.OrderServiceImpl: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.IllegalAccessError-->superinterface check failed: class indi.nonoas.crm.service.impl.OrderServiceImpl$$EnhancerBySpringCGLIB$$776d1e3b (in module CRM) cannot access class org.springframework.aop.framework.Advised (in unnamed module @0x19b6af5f) because module CRM does not read unnamed module @0x19b6af5f