Search code examples
azurewildflyazure-application-insightsjavaagents

Azure Application Insights agent for Java causing Could not find or load main class %JAVA_OPTS on JBoss 18


I am implementing Azure Application Insights in Java application. Azure Docs

I have added below configure in standalone.conf JBOSS/WildFly configuration

However when I start the server I am getting below error

[root@server-1 bin]# ./standalone.sh
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/wildfly

  JAVA: /usr/lib/jvm/jdk1.8.0_261/bin/java

  JAVA_OPTS:  -server %JAVA_OPTS% -javaagent:/tmp/azurejar/applicationinsights-agent-2.6.1.jar

=========================================================================

Error: Could not find or load main class %JAVA_OPTS

Could you please help me to resolve this issue ? Any help is much appreciated.


Solution

  • That's Windows syntax. In a Unix-based environment like Linux you use the $ to access environment variables. Change the %JAVA_OPTS% part of the line to $JAVA_OPTS, i.e.:

    JAVA_OPTS="$JAVA_OPTS -javaagent:/tmp/lib/applicationinsights-agent-2.6.1.jar"