Error bootstrapping New Relic Java agent

Problem

You start up a Java process running with the New Relic Java agent, but data fails to report to the APM UI. You see an Error bootstrapping New Relic agent message in the stack trace in your application logs.

The message Error bootstrapping New Relic agent can indicate multiple failure modes. The stack trace is also key in diagnosing this issue.

Example stack trace when bootstrapping the Java agent
Error bootstrapping New Relic agent: java.lang.RuntimeException: java.io.IOException: No such file or directory

java.lang.RuntimeException: java.io.IOException: No such file or directory

at com.newrelic.bootstrap.BootstrapLoader.load(BootstrapLoader.java:136)

at com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:100)

at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:68)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:382)

at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:397)

Caused by: java.io.IOException: No such file or directory

at java.io.UnixFileSystem.createFileExclusively(Native Method)

at java.io.File.createNewFile(File.java:1006)

at java.io.File.createTempFile(File.java:1989)

at com.newrelic.bootstrap.EmbeddedJarFilesImpl$1.load(EmbeddedJarFilesImpl.java:36)

at com.newrelic.bootstrap.EmbeddedJarFilesImpl$1.load(EmbeddedJarFilesImpl.java:26)

at com.newrelic.agent.deps.com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)

at com.newrelic.agent.deps.com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)

at com.newrelic.agent.deps.com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)

at com.newrelic.agent.deps.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)

at com.newrelic.agent.deps.com.google.common.cache.LocalCache.get(LocalCache.java:3953)

at com.newrelic.agent.deps.com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)

at com.newrelic.agent.deps.com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)

at com.newrelic.bootstrap.EmbeddedJarFilesImpl.getJarFileInAgent(EmbeddedJarFilesImpl.java:66)

at com.newrelic.bootstrap.BootstrapLoader.addBridgeJarToClassPath(BootstrapLoader.java:73)

at com.newrelic.bootstrap.BootstrapLoader.load(BootstrapLoader.java:129)

... 8 more

Solution

If the Java agent cannot create the temporary jar files, it will fail to start up and will return the Error bootstrapping New Relic agent line preceding the stack trace to System.err. If you are using an app server, this usually appears in your app server's error logs.

Here are common reasons for this failure and the solution.

Temp directory is different from java.io.tempdir system property

This failure can occur when you specify a temporary directory location for the Java process that is not the default location specified by java.io.tmpdir. To solve this problem, pass in the system property -Dnewrelic.tempdir=/path/to/tmpdir to the JVM at startup.

New Relic's Java agent will try to use the default temporary directory location for Java (java.io.tempdir) unless this system property is passed in. If you specified a different temporary directory location for the JVM to use, then the default directory location may not exist, or the Java agent may not have write access to it.

Temp directory does not exist at JVM startup

This failure can occur if the temp directory does not exist when the JVM is starting up. The Java agent starts up very early in the JVM's lifecycle. The agent will not attempt to create the temporary directory if it does not already exist.

For example, part of your process lifecycle might be to delete the java temp directory as your process is finishing. In this situation, make sure the java temp directory will be created again before the Java agent next starts up.

User cannot write to existing temp directory

This failure can occur if the temp directory exists but it cannot be written to by the user starting the java process. This prevents the Java agent from starting up successfully.

To solve this problem, verify permissions for the user starting the Java process that is running the Java agent. Make sure the user has write and execute permissions for the temp directory location.

Other troubleshooting tips

If none of these troubleshooting tips work, see the information about providing Java information for troubleshooting.

For more help

Recommendations for learning more: