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

MBean / MXBean issue during native build #2669

Closed
simonDeHero opened this issue Jul 12, 2020 · 6 comments
Closed

MBean / MXBean issue during native build #2669

simonDeHero opened this issue Jul 12, 2020 · 6 comments
Assignees

Comments

@simonDeHero
Copy link

Describe the issue
I am building a smallish Spring Webapp (REST, JPA, Feign client to call other service, putting messages to AWS SQS). I get the following errors:

...
[opa:4649]     (clinit):   6,387.72 ms, 28.56 GB
[opa:4649]   (typeflow): 118,720.35 ms, 28.56 GB
[opa:4649]    (objects): 231,576.89 ms, 28.56 GB
[opa:4649]   (features):  95,322.29 ms, 28.56 GB
[opa:4649]     analysis: 467,939.15 ms, 28.56 GB
Error: Unsupported features in 7 methods
Detailed message:
Error: Detected a MBean server in the image heap. This is currently not supported, but could be changed in the future. Management beans are registered in many global caches that would need to be cleared and properly re-built at image build time. Class of disallowed object: com.sun.jmx.mbeanserver.JmxMBeanServer  Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by 
	reading field java.lang.management.ManagementFactory.platformMBeanServer
Error: Detected a MBean server in the image heap. This is currently not supported, but could be changed in the future. Management beans are registered in many global caches that would need to be cleared and properly re-built at image build time. Class of disallowed object: org.apache.tomcat.util.modeler.NoDescriptorRegistry$NoJmxMBeanServer  Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by 
	reading field org.apache.catalina.mbeans.MBeanUtils.mserver
Error: Detected a MBean server in the image heap. This is currently not supported, but could be changed in the future. Management beans are registered in many global caches that would need to be cleared and properly re-built at image build time. Class of disallowed object: org.apache.tomcat.util.modeler.NoDescriptorRegistry$NoJmxMBeanServer  Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by 
	reading field org.apache.tomcat.util.modeler.NoDescriptorRegistry.mBeanServer of
		constant org.apache.tomcat.util.modeler.NoDescriptorRegistry@32217484 reached by 
	reading field org.apache.catalina.mbeans.MBeanUtils.registry
Error: Detected a PlatformManagedObject (a MXBean defined by the virtual machine) in the image heap. This bean is introspecting the VM that runs the image builder, i.e., a VM instance that is no longer available at image run time. Class of disallowed object: com.sun.management.internal.HotSpotDiagnostic  Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by 
	reading field com.sun.management.internal.PlatformMBeanProviderImpl.hsDiagMBean
Error: Detected a PlatformManagedObject (a MXBean defined by the virtual machine) in the image heap. This bean is introspecting the VM that runs the image builder, i.e., a VM instance that is no longer available at image run time. Class of disallowed object: jdk.management.jfr.FlightRecorderMXBeanImpl  Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by 
	reading field jdk.management.jfr.internal.FlightRecorderMXBeanProvider.flightRecorderMXBean
Error: Detected a PlatformManagedObject (a MXBean defined by the virtual machine) in the image heap. This bean is introspecting the VM that runs the image builder, i.e., a VM instance that is no longer available at image run time. Class of disallowed object: sun.management.ManagementFactoryHelper$1  Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by 
	indexing into array
		constant java.lang.Object[]@59768343 reached by 
	reading field java.util.ArrayList.elementData of
		constant java.util.ArrayList@62c83247 reached by 
	reading field sun.management.ManagementFactoryHelper.bufferPools
...

I also tried to initialize the relevant classes at run-time, but then i got different errors:

...
[opa:4345]     analysis: 243,161.57 ms, 13.39 GB
Error: Classes that should be initialized at run time got initialized during image building:
 com.sun.management.internal.HotSpotDiagnostic the class was requested to be initialized at run time (from the command line). com.sun.management.internal.HotSpotDiagnostic has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of com.sun.management.internal.HotSpotDiagnostic
org.apache.catalina.mbeans.MBeanUtils the class was requested to be initialized at run time (from the command line). org.apache.catalina.mbeans.MBeanUtils has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of org.apache.catalina.mbeans.MBeanUtils
com.sun.jmx.mbeanserver.JmxMBeanServer the class was requested to be initialized at run time (from the command line). com.sun.jmx.mbeanserver.JmxMBeanServer has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of com.sun.jmx.mbeanserver.JmxMBeanServer
...

so it seems, that i am stuck, because initializing during build does not work, and also initializing at run-time does not work either.

Steps to reproduce the issue
I am really sorry, i cannot share the code

Describe GraalVM and your environment:

  • GraalVM version 20.2.0-dev-20200711_0200
  • JDK major version: 11
  • OS: ubuntu 18.04
  • Architecture: AMD64
  • Spring Boot 2.3.0.RELEASE

More details
my build command (snippet):

/opt/graalvm-ce-java11-20.2.0-dev/bin/native-image \
  --verbose \
  --no-server -J-Xmx32G\
  --no-fallback \
  --initialize-at-build-time \
  --enable-all-security-services \
  -H:+TraceClassInitialization \
  --delay-class-initialization-to-runtime=org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping \
  --initialize-at-run-time=org.apache.tomcat.jni.OS \
  --initialize-at-run-time=org.apache.tomcat.util.net.openssl.OpenSSLEngine \
  --initialize-at-run-time=org.springframework.web.reactive.result.method.RequestMappingInfo \
  --initialize-at-run-time=org.springframework.web.reactive.result.condition.PatternsRequestCondition \
  --initialize-at-run-time=org.apache.juli.AsyncFileHandler \
  -H:Name=opa \
  -H:+ReportExceptionStackTraces \
  -Dspring.native.remove-unused-autoconfig=true \
  -Dspring.native.missing-selector-hints=warning \
  -Dspring.native.verbose=true \
  -cp BOOT-INF/classes:$LIBPATH:/home/ubuntu/graalbuild/spring-graal-native-0.7.0.BUILD-SNAPSHOT.jar:/home/ubuntu/graalbuild/spring-webflux-5.2.7.RELEASE.jar \
@simonDeHero
Copy link
Author

bump :-)

@cstancu
Copy link
Member

cstancu commented Jul 28, 2020

@vjovanov would your recent changes to class initialization help avoid these MBean issues? @simonDeHero you could try rebuilding with a dev version that contains #2650.

@simonDeHero
Copy link
Author

thx! i will try then with 20.2, when it is released

@vjovanov
Copy link
Member

Yes, my changes could help with this issue. Let me know if it worked out.

@cstancu
Copy link
Member

cstancu commented Sep 23, 2020

Please reopen if still an issue.

@chuailiwu
Copy link

version OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)
still is an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants