Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Spring Server Chassis - compile failure with Java 16 #5091

Closed
planetf1 opened this issue Apr 28, 2021 · 4 comments
Closed

UI Spring Server Chassis - compile failure with Java 16 #5091

planetf1 opened this issue Apr 28, 2021 · 4 comments
Assignees
Labels
build-failure High Priority - a build is failing java Pull requests that update Java code user-interface User interface

Comments

@planetf1
Copy link
Member

planetf1 commented Apr 28, 2021

The current (non LTS) version of Java fails to compile 'UI Server Platform Chassis for Spring'
Egeria currently supports Java 8 and Java 11, however generally the code does compile with later versions of java, and we aim to keep it compliant.
Opening as a note in case others see this, plus an action to understand/resolve

The failure occurs at:

10:53:59,990 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project ui-chassis-spring: There are test failures.

The root cause is likely down to a change to 'java.naming' not exporting 'com.sun.jndi.ldap'. It's worth noting that 'com.sun' classes have been deprecated in java for many many years and releases, so it may be we have picked up some old or non-compliant code through our spring/java support, which could indicate there are other issues with old/contaminated dependencies:

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ldapHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/ldap/LdapHealthContributorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'ldapHealthContributor' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ldapTemplate' defined in class path resource [org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.class]: Unsatisfied dependency expressed through method 'ldapTemplate' parameter 1; nested exception is 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 @0x11028347) 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 @0x11028347
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ldapHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/ldap/LdapHealthContributorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'ldapHealthContributor' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ldapTemplate' defined in class path resource [org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.class]: Unsatisfied dependency expressed through method 'ldapTemplate' parameter 1; nested exception is 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 @0x11028347) 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 @0x11028347
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ldapHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/ldap/LdapHealthContributorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'ldapHealthContributor' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ldapTemplate' defined in class path resource [org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.class]: Unsatisfied dependency expressed through method 'ldapTemplate' parameter 1; nested exception is 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 @0x11028347) 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 @0x11028347

Full log : https://1drv.ms/u/s!ApVqcIDT57-fluBnuE_WbijVHniAYQ?e=HONhzP

Current java version:

$ java -version                                                                                                              [11:08:40]
openjdk version "16" 2021-03-16
OpenJDK Runtime Environment Zulu16.28+11-CA (build 16+36)
OpenJDK 64-Bit Server VM Zulu16.28+11-CA (build 16+36, mixed mode, sharing)
@planetf1 planetf1 added build-failure High Priority - a build is failing java Pull requests that update Java code user-interface User interface labels Apr 28, 2021
@planetf1
Copy link
Member Author

There's a suggestion that the issue is a missing export - see spring-projects/spring-boot#25527 (though I don't think any code should be using com.sun.* ?)

@planetf1
Copy link
Member Author

WORKAROUND

export JAVA_TOOL_OPTIONS="--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED"

prior to running the build (and probably actually running the code -- as the issue here was in FVT).
This can only be applied in Java 11 & above

Still some investigation here on WHY as this seems an internal java implementation class?

@planetf1
Copy link
Member Author

The referenced issue has lots of references to 2.4.4 changes, but note that we are already using spring boot 2.4.5 and see this issue.

@planetf1
Copy link
Member Author

planetf1 commented Jun 2, 2021

Following June's dependency updates, this now seems to compile ok with Java 16, so closing

@planetf1 planetf1 closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-failure High Priority - a build is failing java Pull requests that update Java code user-interface User interface
Projects
None yet
Development

No branches or pull requests

2 participants