java - Java 的 Application Insights 代理在 JBoss 10 上导致 NoClassDefFoundError

标签 java jboss azure-application-insights

我们可以设置Application Insights in a Java web project对于我们在 JBoss (WildFly) 上的应用程序。这一步没有任何问题,我们可以在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

最佳答案

我遇到了同样的问题,直到我对 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

关于java - Java 的 Application Insights 代理在 JBoss 10 上导致 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48275650/

相关文章:

java - JBoss 推送通知到 Android

用于在数据库池上设置警报的 Azure ARM 模板架构/文档

java - Java 中哪种排序集合实现的内存占用最小?

java - 增加android中颜色的发光度

java - Keycloak注销请求

azure - Azure Application Insights 中的持续时间范围

azure - 在azure日志门户的工作簿中添加参数

java - 附加到先前输出的 JSP 错误页面

java - 如何向 Java 通用通配符列表添加元素

java - 在 Infinispan 中使用共享文件存储时获取 "java.io.IOException: Unsupported protocol version 22"