Application Insights Agent for Java在JBoss 10上导致NoClassDefFoundError

时间:2018-01-16 07:03:47

标签: java jboss azure-application-insights

我们可以在JBoss(WildFly)上为我们的应用设置Application Insights in a Java web project。此步骤没有任何问题,我们可以在Azure门户上看到Web请求的监控数据。

但我们在安装the agent时获得了NoClassDefFoundError

我试图解决这个问题几天没有任何成功。将代理jar添加到我们的应用程序依赖项(WEB-INF/lib)没有帮助。

作为旁注,我们可以使用New Relic Java代理成功运行我们的应用程序。似乎此问题的原因是Application Insights Java代理特有的。

我们的应用程序在Docker容器上运行:

  • 主机:macOS High Sierra 10.13
  • Docker :17.09
  • Docker容器操作系统:Ubuntu 16.04
  • Oracle JDK :1.8
  • JBoss :10.1.0.Final

JBoss日志:

wildfly            |   JBoss Bootstrap Environment
wildfly            | 
wildfly            |   JBOSS_HOME: /opt/wildfly
wildfly            | 
wildfly            |   JAVA: /opt/java/bin/java
wildfly            | 
wildfly            |   JAVA_OPTS:  -server -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/p:/opt/wildfly/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.0.4.Final.jar -Xms64m -Xmx1024m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager -Djava.awt.headless=true -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n -javaagent:/opt/wildfly/applicationinsights/applicationinsights-agent-2.0.0-BETA.jar
wildfly            | 
wildfly            | =========================================================================
wildfly            | 
wildfly            | Listening for transport dt_socket at address: 8787
wildfly            | AI-Agent: INFO 12-01-2018 15:35, 1: Agent jar found at /opt/wildfly/applicationinsights/applicationinsights-agent-2.0.0-BETA.jar
wildfly            | AI-Agent: INFO 12-01-2018 15:35, 1: Agent jar name is applicationinsights-agent-2.0.0-BETA.jar
wildfly            | AI-Agent: TRACE 12-01-2018 15:35, 1: Successfully loaded Agent jar
wildfly            | AI-Agent: INFO 12-01-2018 15:35, 1: Agent is up
wildfly            | 15:35:43,988 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
wildfly            | 15:35:44,116 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
wildfly            | 15:35:44,194 INFO  [org.jboss.as] (MSC service thread 1-4) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting
...
<truncated>
...
wildfly            | Caused by: java.sql.SQLException: java.lang.NoClassDefFoundError: com/microsoft/applicationinsights/agent/internal/coresync/impl/ImplementationsCoordinator
wildfly            |    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)
wildfly            |    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
wildfly            |    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
wildfly            |    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
wildfly            |    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:877)
wildfly            |    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:873)
wildfly            |    at com.mysql.jdbc.Util.handleNewInstance(Util.java:422)
wildfly            |    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
wildfly            |    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
wildfly            |    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)
wildfly            |    ... 28 more
wildfly            | Caused by: java.lang.NoClassDefFoundError: com/microsoft/applicationinsights/agent/internal/coresync/impl/ImplementationsCoordinator
wildfly            |    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1424)
wildfly            |    at com.mysql.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:3833)
wildfly            |    at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3283)
wildfly            |    at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2126)
wildfly            |    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2088)
wildfly            |    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806)
wildfly            |    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
wildfly            |    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
wildfly            |    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
wildfly            |    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
wildfly            |    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
wildfly            |    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
wildfly            |    ... 31 more

2 个答案:

答案 0 :(得分:0)

在对Wildfly使用以下配置之前,我遇到了同样的问题

set JAVA_OPTS=%JAVA_OPTS% -javaagent:D:\workspace\applicationinsights-agent-2.1.1.jar
set JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman,com.singularity,org.jboss.logmanager,com.microsoft.applicationinsights.agent
set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/p:D:/wildfly-10.1.0.Final/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.0.3.Final.jar

答案 1 :(得分:0)

第三行无关紧要,但是第二行包含修复程序。 我还必须在其中添加另一个值: -Djboss.modules.system.pkgs=org.jboss.byteman,com.microsoft.applicationinsights.agent,org.glowroot.instrumentation.api

您还可以在bin / standalone.conf中进行更改 if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then JBOSS_MODULES_SYSTEM_PKGS="org.jboss.bytemancom.microsoft.applicationinsights.agent,org.glowroot.instrumentation.api" fi