将 Java 任务控制连接到 Wildfly 16

Connect Java Mission Control to Wildfly 16

我尝试将 Java 任务控制 (JMC) 连接到 Wildfly 16。应用程序服务器位于 Docker。

我通过 jconsole 成功连接到 wildfly,为了管理它,我遵循了描述的步骤 here

不幸的是,我无法通过 JMC 连接。我使用的 URL 看起来像这样:

service:jmx:remoting-jmx://192.168.99.100:9990

然后,我发现 here 对一些 jboss 类 进行硬编码以通过 remoting-jmx 启用连接的想法。我根据 wildfly16 提供的这些更改了 jar 的版本,并像这样将其放入 jmc.ini。

-Xbootclasspath/a:"C:/Program Files/Java/jdk-10.0.2/lib/missioncontrol/dropins/jboss-cli-client.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/remoting-jmx/main/remoting-jmx-3.0.1.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/remoting/main/jboss-remoting-5.0.8.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/logging/main/jboss-logging-3.3.2.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/xnio/main/xnio-api-3.6.5.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/xnio/nio/main/xnio-nio-3.6.5.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/marshalling/main/jboss-marshalling-2.0.6.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/marshalling/river/main/jboss-marshalling-river-2.0.6.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/as/cli/main/wildfly-cli-8.0.0.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/staxmapper/main/staxmapper-1.3.0.Final;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/as/protocol/main/wildfly-protocol-8.0.0.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/dmr/main/jboss-dmr-1.5.0.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/as/controller-client/main/wildfly-controller-client-8.0.0.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/threads/main/jboss-threads-2.3.3.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.1.7.Final.jar"

在那之后,最后,我还有一个错误,就是

Could not initialize class org.jboss.remotingjmx.RemotingConnector

我在Xbootclasspath中添加了remoting-jmx-3.0.1.Final的依赖,但还是报同样的错误。

我的问题是,您知道如何使此连接有效吗?也许有人用不同的方式做到了?

任何关于如何调试这个问题的建议都是无价的?因为我不知道如何解决它。

  1. %WILDFLY_HOME%\bin\standalone.conf.bat 放:

    设置"JAVA_OPTS=%JAVA_OPTS% -XX:+FlightRecorder"

  2. 在-vmargs下面的jmc.ini中放

    -Xbootclasspath/a:C:\%wildfly_home%\bin\client\jboss-cli-client.jar

(%wildfly_home%当然不一样,或者直接把jboss-cli-client.jar复制到另一个目录改路径即可) 3. 运行 JMC,然后创建新连接 - 在“连接属性”窗格中按下按钮 "Custom JMX service URL",输入:

service:jmx:http-remoting-jmx://localhost:9990    

在凭据字段中只需输入用户和密码,它们应该为领域管理创建(例如使用 %wildfly_home%\bin\add-user.bat) 希望这对某人有所帮助。

解决方案对我来说不适用于 java 11。任务控制在连接到 wildfly 时失败并出现错误:

Caused by: java.lang.NoClassDefFoundError: org/ietf/jgss/GSSManager
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3137)
at java.base/java.lang.Class.getConstructor0(Class.java:3342)
at java.base/java.lang.Class.getConstructor(Class.java:2151)
at java.base/java.security.Provider.newInstanceUtil(Provider.java:152)
at java.base/java.security.Provider$Service.newInstance(Provider.java:1824)
at org.wildfly.security.WildFlyElytronBaseProvider$ProviderService.newInstance(WildFlyElytronBaseProvider.java:218)
at org.wildfly.security.sasl.util.SecurityProviderSaslClientFactory.createSaslClient(SecurityProviderSaslClientFactory.java:94)
at org.wildfly.security.sasl.util.AbstractDelegatingSaslClientFactory.createSaslClient(AbstractDelegatingSaslClientFactory.java:66)
at org.wildfly.security.sasl.util.ProtocolSaslClientFactory.createSaslClient(ProtocolSaslClientFactory.java:50)
at org.wildfly.security.sasl.util.AbstractDelegatingSaslClientFactory.createSaslClient(AbstractDelegatingSaslClientFactory.java:66)
at org.wildfly.security.sasl.util.ServerNameSaslClientFactory.createSaslClient(ServerNameSaslClientFactory.java:50)
at org.wildfly.security.sasl.util.AbstractDelegatingSaslClientFactory.createSaslClient(AbstractDelegatingSaslClientFactory.java:66)
at org.wildfly.security.sasl.util.ServerNameSaslClientFactory.createSaslClient(ServerNameSaslClientFactory.java:50)
at org.wildfly.security.sasl.util.FilterMechanismSaslClientFactory.createSaslClient(FilterMechanismSaslClientFactory.java:102)
at org.wildfly.security.sasl.util.AbstractDelegatingSaslClientFactory.createSaslClient(AbstractDelegatingSaslClientFactory.java:66)
at org.wildfly.security.sasl.util.LocalPrincipalSaslClientFactory.createSaslClient(LocalPrincipalSaslClientFactory.java:76)
at org.wildfly.security.sasl.util.PrivilegedSaslClientFactory.lambda$createSaslClient[=10=](PrivilegedSaslClientFactory.java:64)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.wildfly.security.sasl.util.PrivilegedSaslClientFactory.createSaslClient(PrivilegedSaslClientFactory.java:64)
at org.wildfly.security.auth.client.AuthenticationConfiguration.createSaslClient(AuthenticationConfiguration.java:1545)
at org.wildfly.security.auth.client.AuthenticationContextConfigurationClient.createSaslClient(AuthenticationContextConfigurationClient.java:430)
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:419)
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:244)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)

此外,嵌入到jdk 8 的jmc 无法为java 11 进程启动飞行记录。 所以经过调查我发现这个 class 加载了 bootstrap classloader。根据 https://openjdk.java.net/jeps/261 jdk.security.jgss 模块未定义到 bootstrap class 加载程序。但是jboss-cli-client.jar中的classes(来源于wildfly-elytron项目)在运行时间需要jgss classes。 所以我找到了解决此问题的肮脏解决方法:bootstrap 需要 class 来自 jmc.ini 中的 jre 8。 linux 的完整选项是:

-vmargs -Xbootclasspath/a:<path_to_wildfly>/jboss-cli-client.jar:<path_to_jdk8>/jre/lib/rt.jar

对于windows:

-vmargs -Xbootclasspath/a:<path_to_wildfly>\jboss-cli-client.jar;<path_to_jdk8>\jre\lib\rt.jar

此后jmc(运行 on 11 jdk) 成功连接到wildfly(运行 on 11 jdk)并可以启动和分析飞行记录。