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

[GraalVM]: NotCompliantMBeanException #33677

Closed
smoell opened this issue Jan 3, 2023 · 7 comments
Closed

[GraalVM]: NotCompliantMBeanException #33677

smoell opened this issue Jan 3, 2023 · 7 comments
Assignees
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@smoell
Copy link

smoell commented Jan 3, 2023

Hi all,

my Spring Boot 3 project runs fine if I use Java 17, but after AoT-compilation with GraalVM, I get the following error:

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.1)

2023-01-03T21:02:55.998Z  INFO 1 --- [           main] c.a.c.CustomerServiceApplication         : Starting AOT-processed CustomerServiceApplication using Java 17.0.5 with PID 1 (/CustomerService started by root in /)
2023-01-03T21:02:55.998Z  INFO 1 --- [           main] c.a.c.CustomerServiceApplication         : The following 1 profile is active: "prod"
2023-01-03T21:02:56.021Z  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-01-03T21:02:56.022Z  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-01-03T21:02:56.022Z  INFO 1 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.4]
2023-01-03T21:02:56.027Z  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-01-03T21:02:56.027Z  INFO 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 28 ms
2023-01-03T21:02:56.049Z  WARN 1 --- [           main] i.m.c.i.binder.jvm.JvmGcMetrics          : GC notifications will not be available because MemoryPoolMXBeans are not provided by the JVM
2023-01-03T21:02:56.052Z  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-01-03T21:02:56.130Z  INFO 1 --- [           main] c.a.c.CustomerServiceApplication         : Started CustomerServiceApplication in 0.142 seconds (process running for 0.146)
2023-01-03T21:02:56.132Z ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalArgumentException: javax.management.NotCompliantMBeanException: com.sun.management.ThreadMXBean: Method java.lang.management.ThreadMXBean.getThreadInfo has parameter or return type that cannot be translated into an open type
        at java.management@17.0.5/javax.management.StandardMBean.<init>(StandardMBean.java:271) ~[CustomerService:na]
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.management.ManagementSupport.addMXBean(ManagementSupport.java:301) ~[na:na]
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.management.ManagementSupport.getPlatformMBeanServer(ManagementSupport.java:285) ~[na:na]
        at java.management@17.0.5/java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:45) ~[CustomerService:na]
        at io.micrometer.core.instrument.binder.tomcat.TomcatMetrics.getMBeanServer(TomcatMetrics.java:98) ~[na:na]
        at io.micrometer.core.instrument.binder.tomcat.TomcatMetrics.<init>(TomcatMetrics.java:72) ~[na:na]
        at org.springframework.boot.actuate.metrics.web.tomcat.TomcatMetricsBinder.onApplicationEvent(TomcatMetricsBinder.java:63) ~[CustomerService:3.0.1]
        at org.springframework.boot.actuate.metrics.web.tomcat.TomcatMetricsBinder.onApplicationEvent(TomcatMetricsBinder.java:42) ~[CustomerService:3.0.1]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[na:na]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[na:na]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[na:na]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413) ~[CustomerService:6.0.3]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370) ~[CustomerService:6.0.3]
        at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:103) ~[CustomerService:3.0.1]
        at org.springframework.boot.SpringApplicationRunListeners.lambda$started$5(SpringApplicationRunListeners.java:76) ~[na:na]
        at java.base@17.0.5/java.lang.Iterable.forEach(Iterable.java:75) ~[CustomerService:na]
        at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118) ~[na:na]
        at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112) ~[na:na]
        at org.springframework.boot.SpringApplicationRunListeners.started(SpringApplicationRunListeners.java:76) ~[na:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[CustomerService:3.0.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[CustomerService:3.0.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[CustomerService:3.0.1]
        at com.amazon.customerService.CustomerServiceApplication.main(CustomerServiceApplication.java:45) ~[CustomerService:na]
Caused by: javax.management.NotCompliantMBeanException: com.sun.management.ThreadMXBean: Method java.lang.management.ThreadMXBean.getThreadInfo has parameter or return type that cannot be translated into an open type
        at java.management@17.0.5/com.sun.jmx.mbeanserver.Introspector.throwException(Introspector.java:468) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MBeanAnalyzer.<init>(MBeanAnalyzer.java:120) ~[CustomerService:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MBeanAnalyzer.analyzer(MBeanAnalyzer.java:102) ~[CustomerService:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MXBeanIntrospector.getAnalyzer(MXBeanIntrospector.java:74) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MBeanIntrospector.getPerInterface(MBeanIntrospector.java:192) ~[CustomerService:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MBeanSupport.<init>(MBeanSupport.java:138) ~[CustomerService:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MXBeanSupport.<init>(MXBeanSupport.java:66) ~[na:na]
        at java.management@17.0.5/javax.management.StandardMBean.construct(StandardMBean.java:175) ~[CustomerService:na]
        at java.management@17.0.5/javax.management.StandardMBean.<init>(StandardMBean.java:269) ~[CustomerService:na]
        ... 22 common frames omitted
Caused by: java.lang.IllegalArgumentException: Method java.lang.management.ThreadMXBean.getThreadInfo has parameter or return type that cannot be translated into an open type
        at java.management@17.0.5/com.sun.jmx.mbeanserver.ConvertingMethod.from(ConvertingMethod.java:46) ~[CustomerService:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MXBeanIntrospector.mFrom(MXBeanIntrospector.java:84) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MXBeanIntrospector.mFrom(MXBeanIntrospector.java:54) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MBeanAnalyzer.initMaps(MBeanAnalyzer.java:137) ~[CustomerService:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.MBeanAnalyzer.<init>(MBeanAnalyzer.java:118) ~[CustomerService:na]
        ... 29 common frames omitted
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: java.lang.management.ThreadInfo[]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.openDataException(DefaultMXBeanMappingFactory.java:1539) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.mappingForType(DefaultMXBeanMappingFactory.java:261) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.ConvertingMethod.<init>(ConvertingMethod.java:212) ~[CustomerService:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.ConvertingMethod.from(ConvertingMethod.java:41) ~[CustomerService:na]
        ... 33 common frames omitted
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: java.lang.management.ThreadInfo
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.openDataException(DefaultMXBeanMappingFactory.java:1539) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.mappingForType(DefaultMXBeanMappingFactory.java:261) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.makeArrayOrCollectionMapping(DefaultMXBeanMappingFactory.java:319) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.makeMapping(DefaultMXBeanMappingFactory.java:289) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.mappingForType(DefaultMXBeanMappingFactory.java:259) ~[na:na]
        ... 35 common frames omitted
Caused by: javax.management.openmbean.OpenDataException: Can't map java.lang.management.ThreadInfo to an open data type
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.makeCompositeMapping(DefaultMXBeanMappingFactory.java:462) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.makeMapping(DefaultMXBeanMappingFactory.java:294) ~[na:na]
        at java.management@17.0.5/com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.mappingForType(DefaultMXBeanMappingFactory.java:259) ~[na:na]
        ... 38 common frames omitted
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 3, 2023
@wilkinsona
Copy link
Member

This looks to be very similar to #33210 and I suspect that it has a similar cause. Specifically, I suspect that either your app or the reachability metadata for one of its dependencies has MBean-related entries that it should not have. If you can provide a minimal sample that reproduces the problem, we can help to pinpoint its cause.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jan 4, 2023
@smoell
Copy link
Author

smoell commented Jan 4, 2023

Hi, thank you for the quick reply, the project can be found here:

https://github.com/smoell/spring-graalvm-issue

How to reproduce:

$ git clone https://github.com/smoell/spring-graalvm-issue.git
$ cd spring-graalvm-issue/spring-native/CustomerService
$ docker build -t spring/customer -f Dockerfile .
$ docker run spring/customer

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 4, 2023
@wilkinsona wilkinsona self-assigned this Jan 5, 2023
@wilkinsona
Copy link
Member

Thanks for the sample.

The problem's caused by your dependency on Undertow. Its reachability metadata contains MBean-related entries that are harmful.

Your application isn't actually using Undertow anyway as it still has Tomcat on the classpath and it is preferred. This means that, until the reachability metadata is fixed, you can avoid the problem by removing the dependency on spring-boot-starter-undertow.

@smoell
Copy link
Author

smoell commented Jan 5, 2023

Thank you, will try!

@smoell
Copy link
Author

smoell commented Jan 5, 2023

That solved the issue, thank you!

@smoell smoell closed this as completed Jan 5, 2023
@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2023
@wilkinsona
Copy link
Member

Great. Thanks for letting us know. oracle/graalvm-reachability-metadata#161 will hopefully fix the problem with Undertow.

@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Jan 5, 2023
@rishiraj88
Copy link

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants