2

目前我们在一个基于 Java 8 的自创 Docker 镜像中运行 Wildfly(版本 17.0.1.Final)。为了通过 Prometheus 监控我们的应用程序,我们安装jmx_exporter并配置了它,如下所示。

现在我们想切换到jboss/wildfly:17.0.1.Final使用 Java 11 的官方 Docker 镜像。使用我们当前的配置时,无法创建 JVM,因为-Xbootclasspath/p不再支持。只有-Xbootclasspath/a-Xbootclasspath有效。

只是替换-Xbootclasspath/p不起作用-Xbootclasspath/a,并在启动时给出以下错误消息:

Could not load Logmanager "org.jboss.logmanager.LogManager"
java.lang.ClassNotFoundException: org.jboss.logmanager.LogManager
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.logging/java.util.logging.LogManager$1.run(LogManager.java:239)
    at java.logging/java.util.logging.LogManager$1.run(LogManager.java:223)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.logging/java.util.logging.LogManager.<clinit>(LogManager.java:223)
    at java.logging/java.util.logging.Logger.demandLogger(Logger.java:648)
    at java.logging/java.util.logging.Logger.getLogger(Logger.java:717)
    at java.logging/java.util.logging.Logger.getLogger(Logger.java:701)
    at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.<clinit>(JmxCollector.java:38)
    at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:29)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
    at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
WARNING: Failed to load the specified log manager class org.jboss.logmanager.LogManager

Java 8 的配置

(摘自我们的Dockerfile

# Prometheus (JMX Exporter)
# Versions must match those provided by application server.
# https://lazarbulic.com/blog/2018/05/25/prometheus-jmx_exporter-for-jboss-wildfly/
# We need to add these JARs explicitly to avoid a NoClassDefFoundError.
# https://stackoverflow.com/questions/55874743/noclassdeffounderror-when-using-jmx-exporter-with-wildfly-15
ENV PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/wildfly/common/main/wildfly-common-$WILDFLY_COMMON_VERSION.jar"
ENV PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-$JBOSS_LOG_MANAGER_VERSION.jar"
ENV PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/jboss/log4j/logmanager/main/log4j-jboss-logmanager-$LOG4J_JBOSS_LOGMANAGER_VERSION.jar"
ENV PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/slf4j/impl/main/slf4j-jboss-logmanager-$SLF4J_JBOSS_LOGMANAGER_VERSION.jar"
ENV PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager"
ENV PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JBOSS_MANAGEMENT_PORT -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=$JBOSS_MANAGEMENT_PORT  -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=localhost"
ENV PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -javaagent:$JBOSS_HOME/prometheus/jmx-prometheus.jar=$PROMETHEUS_PORT:$JBOSS_HOME/prometheus/config.yaml"
4

0 回答 0