Docs » Instrument back-end applications to send spans to Splunk APM » Instrument Java applications for Splunk Observability Cloud » Define agent paths for Java application servers for Splunk Observability Cloud

Define agent paths for Java application servers for Splunk Observability Cloud 🔗

To instrument your Java application for Splunk Observability Cloud, you must define the path to the agent from the Splunk Distribution of OpenTelemetry Java. The following sections describe how to set the agent path for each of the supported servers:

JBoss EAP and WildFly 🔗

Add the javaagent argument to the standalone configuration file:

On Linux add the following line at the end of the standalone.conf file:

JAVA_OPTS="$JAVA_OPTS -javaagent:/path/to/splunk-otel-javaagent.jar"

Jetty 🔗

Add the path to the JVM agent using the -javaagent argument:

java -javaagent:/path/to/splunk-otel-javaagent.jar -jar start.jar

Alternatively, you can add the -javaagent argument to your jetty.sh or start.ini files:

  • If you use the jetty.sh file to start Jetty, add the following line to the <jetty_home>/bin/jetty.sh file:

    JAVA_OPTIONS="${JAVA_OPTIONS} -javaagent:/path/to/splunk-otel-javaagent.jar"
    
  • If you use the start.ini file to define JVM arguments, add the javaagent argument below the --exec option:

    #===========================================================
    # Sample Jetty start.ini file
    #-----------------------------------------------------------
    --exec
    -javaagent:/path/to/splunk-otel-javaagent.jar
    

Glassfish and Payara 🔗

Add the path to the JVM agent to the settings using the asadmin command-line tool:

  • On Linux, enter the following command:

    <server_install_dir>/bin/asadmin create-jvm-options "-javaagent\:/path/to/splunk-otel-javaagent.jar"
    
  • On Windows, enter the following command:

    <server_install_dir>\bin\asadmin.bat create-jvm-options '-javaagent\:<Drive>\:\\path\\to\\splunk-otel-javaagent.jar'
    

You can also add the -javaagent argument from the Glassfish or Payara Admin Console:

  1. Open the GlassFish Admin Console at http://localhost:4848.

  2. Go to Configurations > server-config > JVM Settings.

  3. Select JVM Options and click Add JVM Option.

  4. In the blank field, enter the path to the splunk-otel-javaagent.jar file:

    -javaagent:/path/to/splunk-otel-javaagent.jar

  5. Click Save and restart the server.

Note

Make sure that the domain.xml file in your domain directory contains a <jmv-options> entry for the agent.

Tomcat and TomEE 🔗

Add the path to the JVM agent to your Tomcat or TomEE startup script:

On Linux, add the following line to the <tomcat_home>/bin/setenv.sh file:

CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/splunk-otel-javaagent.jar"

WebLogic 🔗

Add the path to the JVM agent to your WebLogic domain startup script:

  • On Linux, add the following line to the <domain_home>/bin/startWebLogic.sh file:

    export JAVA_OPTIONS="$JAVA_OPTIONS -javaagent:/path/to/splunk-otel-javaagent.jar"
    
  • On Windows, add the following line to the <domain_home>binstartWebLogic.cmd file:

    set JAVA_OPTIONS=%JAVA_OPTIONS% -javaagent:"<Drive>:\path\to\splunk-otel-javaagent.jar"
    

Note

For managed server instances, add the -javaagent argument using the admin console.

WebSphere Liberty Profile 🔗

Add the path to the JVM agent to the jvm.options file:

  1. Open the jvm.options file: - For a single server, create or edit the ${server.config.dir}/jvm.options file. - For all servers, create or edit the ${wlp.install.dir}/etc/jvm.options file.

  2. Add the following line:

    -javaagent:/path/to/splunk-otel-javaagent.jar
    
  3. Save the file and restart the server.

WebSphere Traditional 🔗

Open the WebSphere Admin Console and follow these steps:

  1. Navigate to Servers > Server type > WebSphere application servers.

  2. Select the desired server.

  3. Navigate to Java and Process Management > Process Definition.

  4. Select Java Virtual Machine.

  5. In the Generic JVM arguments field, enter the path to Splunk Java agent:

    -javaagent:/path/to/splunk-otel-javaagent.jar
    
  6. Click OK. When asked, save the master configuration and restart the server.