We could setup Application Insights in a Java web project for our app on JBoss (WildFly). There were no any issues on this step and we can see monitoring data for web requests on the Azure portal.
But we are getting the NoClassDefFoundError when installing the agent.
I tried to solve this issue for a couple of days without any success. Adding the agent jar to our app dependecies (WEB-INF/lib) didn't help.
As a side note, we could get our app successfully running with the New Relic Java agent. Seems a reason for this issue is specific to the Application Insights Java agent.
Our app is running on a Docker container:
- Host machine: macOS High Sierra 10.13
- Docker: 17.09
- Docker container OS: Ubuntu 16.04
- Oracle JDK: 1.8
- JBoss: 10.1.0.Final
JBoss logs:
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