'New Relic fails to start because BootstrapAgent throws ClassNotFound

Trying to get New Relic to work with my Play 2.3.4 app.

Here's the error I'm getting:

Exception in thread "main" java.lang.ClassNotFoundException: com.newrelic.bootstrap.BootstrapAgent
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:304)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
FATAL ERROR in native method: processing of -javaagent failed

and my start command is:

sudo ./app -J-javaagent:../../newrelic/newrelic.jar

Any help really appreciated.



Solution 1:[1]

Try adding the javaagent flag as part of the JAVA_OPTS env variable and running your application:

export JAVA_OPTS="$JAVA_OPTS -javaagent:/full/path/to/newrelic.jar"
sudo ./app

If this doesn't work, try the New Relic community forum for additional help. https://discuss.newrelic.com/

Solution 2:[2]

It is not recommended to use relative paths when setting your agent.

Try using the full path to the jar file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tommy
Solution 2 André Onuki