Search code examples
ibm-mqjava-11quarkusgraalvm-native-image

quarkus + java mq client + com.sun.jmx.mbeanserver.JmxMBeanServer


Hi below is the command I am running to create a native image of an existing java mq client I have.

C:\Users\cmishr4\work\graalvmcejava112110\bin\native-image.cmd -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 -DUHG_ENVIRONMENT=MTST1 -DENV=MTST1 -DbackingStoreClassName=com.uhg.uht.tool.configuration.JSONBackingStore -DconfigurationClassName=com.uhg.uht.tool.configuration.StrictConfiguration -DWEBINFPATH=C:/Users/cmishr4/work/wrkspcs/eclipse/com.optum.tg.srvcs/src/main/webapp -DUHG_CONFIG_ROOT=C:/Users/cmishr4/work/wrkspcs/eclipse/com.optum.tg.srvcs/src/main/webapp/WEB-INF/config/uhg_config -Dserver.port=8080 -Djavax.net.ssl.keyStore=C:/Users/cmishr4/work/comet/ssl/conf/cometdesktop.optum.com.jks -Djavax.net.ssl.trustStore=C:/Users/cmishr4/work/comet/ssl/conf/cometdesktop.optum.com.jks -Djavax.net.ssl.keyStorePassword=<<password>> -Dcom.ibm.mq.cfg.useIBMCipherMappings=false -Dlogback.configurationFile=C:/Users/cmishr4/work/wrkspcs/eclipse/com.optum.tg.srvcs/src/main/webapp/WEB-INF/config/uhg_config/global_logging_config.xml --report-unsupported-elements-at-runtime --trace-class-initialization=org.apache.http.conn.ssl.SSLConnectionSocketFactory --allow-incomplete-classpath --initialize-at-run-time=com.sun.jmx.mbeanserver.JmxMBeanServer -H:IncludeResourceBundles=javax.xml.bind.Messages -H:ReflectionConfigurationFiles=reflect.json -H:-UseServiceLoaderFeature --no-server --no-fallback -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -jar com.optum.tg.srvcs-1.0.0-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https -H:-UseServiceLoaderFeature -H:+StackTrace com.optum.tg.srvcs-1.0.0-runner

while running this I get the following error

[com.optum.tg.srvcs-1.0.0-runner:15264]     analysis:  61,152.02 ms,  4.97 GB
Error: Classes that should be initialized at run time got initialized during image building:
 com.sun.jmx.mbeanserver.JmxMBeanServer the class was requested to be initialized at run time (from the command line). To see why com.sun.jmx.mbeanserver.JmxMBeanServer got initialized use --trace-class-initialization=com.sun.jmx.mbeanserver.JmxMBeanServer
        com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
        com.sun.jmx.mbeanserver.JmxMBeanServer the class was requested to be initialized at run time (from the command line). To see why com.sun.jmx.mbeanserver.JmxMBeanServer got initialized use --trace-class-initialization=com.sun.jmx.mbeanserver.JmxMBeanServer
        at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:545)
        at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:228)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$14(NativeImageGenerator.java:765)
        at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:71)
        at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:765)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:582)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$2(NativeImageGenerator.java:495)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Error: Image build request failed with exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:24 min
[INFO] Finished at: 2021-08-23T00:11:19-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.1.1.Final:build (default) on project com.optum.tg.srvcs: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:235)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:829)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] Caused by: java.lang.RuntimeException: Image generation failed. Exit code: 1
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:377)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:205)
[ERROR]         ... 11 more
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Do I have to upgrade the version of graalvm to solve this issue? Should I trace from where com.sun.jmx.mbeanserver.JmxMBeanServer is getting initialized (using --trace-class-initialization=com.sun.jmx.mbeanserver.JmxMBeanServer) and put the class as a value for --initialize-at-run-time argument?


Solution

  • Unfortunately the optimisation inside the IBM MQ Java Client makes it incompatible with GraalVM.

    There is, however, an alternative. The Qpid JMS Client can be used to connect to IBM MQ. There is tutorial with code samples available at https://developer.ibm.com/tutorials/mq-running-ibm-mq-apps-on-quarkus-and-graalvm-using-qpid-amqp-jms-classes/

    The associated samples can be found here - https://github.com/ibm-messaging/mq-dev-patterns/tree/master/amqp-qpid