spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Unnamed module issue when using FailureAnalyzer with JPMS

Open eallais opened this issue 3 years ago • 1 comments

I am trying to make FailureAnalyzer working with Java Platform Module System (JPMS) on JDK 11.

FailureAnalyzer is working great when there is not module-info.java, in contrary when this file exists I've got this stacktrace:

Caused by: java.lang.IllegalAccessException: module com.example.failureanalyzer does not open com.example.failureanalyzer to unnamed module @3b74ac8
	at java.base/java.lang.invoke.MethodHandles.privateLookupIn(MethodHandles.java:202) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:506) ~[spring-core-5.3.21.jar:5.3.21]
	... 27 common frames omitted

Here is the content of module-info.java:

module com.example.failureanalyzer {
    requires spring.context;
    requires spring.beans;
    requires spring.boot.autoconfigure;
    requires spring.boot;
}

eallais avatar Jul 27 '22 15:07 eallais

I think this might be a duplicate of #27753, since Spring Boot's FailureAnalyzer infrastructure is loaded with SpringFactoriesLoader.

bclozel avatar Jul 27 '22 16:07 bclozel

The stacktrace above suggests that a CGLIB proxy is being created from a class in that package. If that is unavoidable, the module needs to be declared as open: https://stackoverflow.com/questions/46482364/what-is-an-open-module-in-java-9-and-how-do-i-use-it - otherwise its visibility is too restricted for such proxy purposes.

@bclozel not sure this is related to SpringFactoriesLoader, actually, it rather looks like a CGLIB proxy requirement.

jhoeller avatar Feb 14 '23 11:02 jhoeller

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Feb 28 '23 10:02 spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-projects-issues avatar Mar 07 '23 10:03 spring-projects-issues