首页 > 解决方案 > quarkus + java mq 客户端 + com.sun.jmx.mbeanserver.JmxMBeanServer

问题描述

嗨,下面是我正在运行的命令,以创建我拥有的现有 java mq 客户端的本机映像。

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

运行此程序时出现以下错误

[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

我是否必须升级 graalvm 的版本才能解决此问题?我应该从哪里开始追踪com.sun.jmx.mbeanserver.JmxMBeanServer(使用--trace-class-initialization=com.sun.jmx.mbeanserver.JmxMBeanServer)并将类作为--initialize-at-run-time参数的值吗?

标签: ibm-mqjava-11quarkusgraalvm-native-image

解决方案


不幸的是,IBM MQ Java Client 内部的优化使其与 GraalVM 不兼容。

然而,还有一个替代方案。Qpid JMS 客户端可用于连接到 IBM MQ。https://developer.ibm.com/tutorials/mq-running-ibm-mq-apps-on-quarkus-and-graalvm-using-qpid-amqp-jms-classes/上提供了带有代码示例的教程

相关示例可在此处找到 - https://github.com/ibm-messaging/mq-dev-patterns/tree/master/amqp-qpid


推荐阅读