• English日本語한국어
  • Log inStart now

Include the Java agent with a JVM argument

This document describes how to pass the -javaagent argument to the JVM for your framework. This installation step ensures the agent is included in your app. For all app servers, ensure you pass the full path to the newrelic.jar file.

This document is simply a reference for how to pass the argument. For detailed installation procedures, see Java agent installation.

ColdFusion

To pass the -javaagent argument on ColdFusion:

  1. Start your ColdFusion server and navigate to your ColdFusion admin console.

  2. From the left menu, select SERVER SETTINGS > Java and JVM.

  3. If using the agent API: Specify the path to newrelic-api.jar in the ColdFusion Class Path field.

  4. In the JVM Arguments field, add the -javaagent argument:

    -javaagent:/full/path/to/newrelic.jar
  5. Select Submit Changes, then restart your ColdFusion server.

Geronimo

To pass the -javaagent argument on Geronimo, refer to the New Relic agent jar in the JAVA_OPTS environment variable when running the startup command:

bash
$
export JAVA_OPTS="$JAVA_OPTS -javaagent:/full/path/to/newrelic.jar" && geronimo run

Glassfish

To pass the -javaagent argument on Glassfish:

  1. From the Glassfish console, select Application Server > JVM Settings > JVM options.

  2. On the JVM options page, select Add JVM option.

  3. Add an entry for the -javaagent argument:

    -javaagent:/full/path/to/newrelic.jar
  4. Save and restart Glassfish.

If Glassfish does not start, the -javaagent argument might not have been set correctly. You can change the server JVM arguments by editing the domain.xml file.

Important

A bug in Glassfish 2.1 prevents classes on the bootstrap class loader (the New Relic agent) from using the Java logging API. This appears to be fixed in 2.1.1 or higher releases.

Grails

To pass the -javaagent argument on Grails:

JBoss

To pass the -javaagent argument on JBoss:

Jetty

To pass the -javaagent argument on Jetty:

Play

To pass the -javaagent argument on Play:

Resin

Java 8

  • Option 1: Add the javaagent argument via the jvmargs property in server's resin.properties file:
    jvm_args : -javaagent:/full/path/to/newrelic.jar
  • Option 2: Specify the -javaagent argument by adding it to the <jvm-args> section in your conf/resin.conf or conf/resin.xml file:
    <jvm-arg>-javaagent:/full/path/to/newrelic.jar</jvm-arg>

Java 9 or higher

The module system introduced in Java 9 can lead to the exception NoClassDefFoundError: java/sql/SQLException if the -javaagent property is added to the conf/resin.conf or conf/resin.xml files. If you're using Java 9 or higher make sure that the -javaagent property is not included in those files.

Resin can be run on Java 9 or higher, with the Java agent using one of the following options:

  • Option 1: Add the javaagent argument via the jvmargs property in server's resin.properties file:

    jvm_args : -javaagent:/full/path/to/newrelic.jar

    The Resin server can then be run with ./bin/resin.sh start.

  • Option 2: Run resin jar with the -javaagent property on the command line:

    java -javaagent:/path/to/newrelic.jar -jar lib/resin.jar start

Important

The agent will not work with Resin on Windows when using Java 9 or higher.

Solr

To pass the -javaagent argument on Solr:

Spring Boot

To pass the -javaagent argument on Spring Boot, add it to the command line in which you start your app. Make sure to add it before the -jar argument:

bash
$
java -javaagent:/full/path/to/newrelic.jar -jar app.jar

Tanuki Wrapper

To pass the -javaagent argument on Tanuki Wrapper, add a wrapper option wrapper.conf. In the line below, substitute XXX for an unused number in this file:

wrapper.java.additional.XXX=-javaagent:/full/path/to/newrelic.jar

Tip

On Linux systems, no quotation marks are required when setting this value. This behavior may vary on other operating systems.

Tomcat

To pass the -javaagent argument on Tomcat:

WebLogic

To pass the -javaagent argument on WebLogic:

WebSphere

To pass the -javaagent argument on WebSphere:

  1. From the admin console, select Servers > Application servers > (select a server) > Configuration > Service Infrastructure > Java and Process Management.

  2. Select Process Definition > Additional Properties, then select Java Virtual Machine.

  3. In the Generic JVM arguments field, add the -javaagent argument for your newrelic.jar file:

    -javaagent:/full/path/to/newrelic.jar
  4. Select Apply, then select Save.

  5. Restart your server.

For more information, see the documentation about collecting WebSphere PMI metrics.

WebSphere Community

To pass the -javaagent argument on WebSphere Community Edition, refer to the New Relic agent jar in the JAVA_OPTS environment variable when running the startup command:

bash
$
export JAVA_OPTS="$JAVA_OPTS -javaagent:/full/path/to/newrelic.jar" && startup

WebSphere Liberty Profile

To pass the -javaagent argument on WebSphere Liberty Profile:

  1. Edit ${server.config.dir}/jvm.options.

  2. Add the -javaagent argument to point to your newrelic.jar file:

    -javaagent:/full/path/to/newrelic.jar
  3. Restart your server.

Wildfly

To pass the -javaagent argument on Wildfly (if using Wildfly 11 or higher, see additional install instructions):

Other application servers

The New Relic Java agent works on any supported app server. If your app server is not listed in this document, follow standard procedures for your app server to pass this argument to the JVM before the app jar:

-javaagent:/full/path/to/newrelic.jar
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.