'NoClassDefFoundError: /io/smallrye/common/net/HostName' on containerized Wildfly after adding vFunction Agent



Overview

This issue occurs in the following circumstances

  1. A vFunction Organization installs the Monolithic Java Runtime Agent on their Containerized Application running on a Wildfly Application Server
  2. After adding the Java Agent hooks into the Application an error is unexpectedly thrown
WARNING: Failed to instantiate LoggerFinder provider; Using default.
java.lang.NoClassDefFoundError: io/smallrye/common/net/HostName
        at org.wildfly.common.net.HostName.getQualifiedHostName(HostName.java:50)
        at org.jboss.logmanager.ExtLogRecord.<init>(ExtLogRecord.java:87)
        at org.jboss.logmanager.Logger.log(Logger.java:798)
        at org.jboss.logging@3.6.1.Final//org.jboss.logging.JBossLogManagerLogger.doLogf(JBossLogManagerLogger.java:56)
        at org.jboss.logging@3.6.1.Final//org.jboss.logging.Logger.logf(Logger.java:2400)
        at org.jboss.msc@1.5.6.Final//org.jboss.msc.service.ServiceLogger_$logger.greeting(ServiceLogger_$logger.java:41)
        at org.jboss.msc@1.5.6.Final//org.jboss.msc.service.ServiceContainerImpl.<clinit>(ServiceContainerImpl.java:88)
        at org.jboss.msc@1.5.6.Final//org.jboss.msc.service.ServiceContainer$Factory.create(ServiceContainer.java:253)
        at org.jboss.as.server@30.0.0.Final//org.jboss.as.server.BootstrapImpl$ShutdownHook.register(BootstrapImpl.java:227)
        at org.jboss.as.server@30.0.0.Final//org.jboss.as.server.BootstrapImpl.<init>(BootstrapImpl.java:55)
        at org.jboss.as.server@30.0.0.Final//org.jboss.as.server.Bootstrap$Factory.newInstance(Bootstrap.java:272)
        at org.jboss.as.server@30.0.0.Final//org.jboss.as.server.Main.main(Main.java:90)
        at org.jboss.modules.Module.run(Module.java:345)
        at org.jboss.modules.Module.run(Module.java:313)
        at org.jboss.modules.Main.main(Main.java:612)

Steps to Resolve

This issue is due to an incompatibility between the wildfly-common, jboss-logmanager and the smallrye-common packages that are shipped by default in some Wildfly Application Servers. This issue can be resolved by upgrading to the latest version of Smallrye.

Incompatible versions:

  • Jboss-logmanager-2.1.19.FINAL.jar
  • Wildfly-common-2.0.1.jar
  • Smallrye-common-*.2.13.9.jar

Compatible versions:

  • Jboss-logmanager-2.1.19.FINAL.jar
  • Wildfly-common-2.0.1.jar
  • Smallrye-common-*.2.17.0.jar

Take the following steps to resolve this issue by adding the Smallrye-common to the appropriate Wildfly Modules subdirectories and adding these packages to the Xclassbootpath. The example below can be used for a Containerized Wildfly:

### Note that, in this example, the JBOSS_HOME is /wildfly
ADD https://repo1.maven.org/maven2/io/smallrye/common/smallrye-common-constraint/2.17.0/smallrye-common-constraint-2.17.0.jar /wildfly/modules/system/layers/base/io/smallrye/common/constraint/main/smallrye-common-constraint-2.17.0.jar
ADD https://repo1.maven.org/maven2/io/smallrye/common/smallrye-common-cpu/2.17.0/smallrye-common-cpu-2.17.0.jar /wildfly/modules/system/layers/base/io/smallrye/common/cpu/main/smallrye-common-cpu-2.17.0.jar
ADD https://repo1.maven.org/maven2/io/smallrye/common/smallrye-common-expression/2.17.0/smallrye-common-expression-2.17.0.jar /wildfly/modules/system/layers/base/io/smallrye/common/expression/main/smallrye-common-expression-2.17.0.jar
ADD https://repo1.maven.org/maven2/io/smallrye/common/smallrye-common-function/2.17.0/smallrye-common-function-2.17.0.jar /wildfly/modules/system/layers/base/io/smallrye/common/function/main/smallrye-common-function-2.17.0.jar
ADD https://repo1.maven.org/maven2/io/smallrye/common/smallrye-common-net/2.17.0/smallrye-common-net-2.17.0.jar /wildfly/modules/system/layers/base/io/smallrye/common/net/main/smallrye-common-net-2.17.0.jar
ADD https://repo1.maven.org/maven2/io/smallrye/common/smallrye-common-os/2.17.0/smallrye-common-os-2.17.0.jar /wildfly/modules/system/layers/base/io/smallrye/common/os/main/smallrye-common-os-2.17.0.jar
ADD https://repo1.maven.org/maven2/io/smallrye/common/smallrye-common-ref/2.17.0/smallrye-common-ref-2.17.0.jar /wildfly/modules/system/layers/base/io/smallrye/common/ref/main/smallrye-common-ref-2.17.0.jar

### Note that, in this example, /vfunction is the base vFunction installation directory
ENV JAVA_OPTS="-agentpath:/vfunction/opt/vfunction/agent/libJVMTIAgent.so=conf=/vfunction/etc/sysconfig/vfunction/agent/instances/default-java/native-conf.json -javaagent:/vfunction/opt/vfunction/agent/runtime-agent.jar=ConfigLocation=/vfunction/etc/sysconfig/vfunction/agent/instances/default-java/vfunction-runtime-override.properties -Dcom.vfunction.logging.logFile=/vfunction/var/log/vfunction/instances/default-java/vfagent.log -Dsun.util.logging.disableCallerCheck=true -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager,com.vfunction,vfrtshadow -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/a:/wildfly/modules/system/layers/base/org/wildfly/common/main/wildfly-common-2.0.1.jar -Xbootclasspath/a:/wildfly/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.1.19.Final.jar -Xbootclasspath/a:/wildfly/modules/system/layers/base/io/smallrye/common/constraint/main/smallrye-common-constraint-2.17.0.jar -Xbootclasspath/a:/wildfly/modules/system/layers/base/io/smallrye/common/cpu/main/smallrye-common-cpu-2.17.0.jar -Xbootclasspath/a:/wildfly/modules/system/layers/base/io/smallrye/common/expression/main/smallrye-common-expression-2.17.0.jar -Xbootclasspath/a:/wildfly/modules/system/layers/base/io/smallrye/common/function/main/smallrye-common-function-2.17.0.jar -Xbootclasspath/a:/wildfly/modules/system/layers/base/io/smallrye/common/net/main/smallrye-common-net-2.17.0.jar -Xbootclasspath/a:/wildfly/modules/system/layers/base/io/smallrye/common/os/main/smallrye-common-os-2.17.0.jar -Xbootclasspath/a:/wildfly/modules/system/layers/base/io/smallrye/common/ref/main/smallrye-common-ref-2.17.0.jar $JAVA_OPTS"