[Java] New Relic APM error with WSO2 Carbon

Hello @andei.diaconu,

Am trying to integrate newrelic for wso2-5.11.0 ,Am facing below error

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:139)
at com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:116)
at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:84)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.io.IOException: No such file or directory
at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.base/java.io.File.createTempFile(File.java:2092)
at com.newrelic.bootstrap.EmbeddedJarFilesImpl$1.load(EmbeddedJarFilesImpl.java:43)
at com.newrelic.bootstrap.EmbeddedJarFilesImpl$1.load(EmbeddedJarFilesImpl.java:33)
at com.newrelic.agent.deps.com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3445)
at com.newrelic.agent.deps.com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2194)
at com.newrelic.agent.deps.com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2153)
at com.newrelic.agent.deps.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2043)
at com.newrelic.agent.deps.com.google.common.cache.LocalCache.get(LocalCache.java:3849)
at com.newrelic.agent.deps.com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3873)
at com.newrelic.agent.deps.com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4798)
at com.newrelic.bootstrap.EmbeddedJarFilesImpl.getJarFileInAgent(EmbeddedJarFilesImpl.java:70)
at com.newrelic.bootstrap.BootstrapLoader.addBridgeJarToClassPath(BootstrapLoader.java:78)
at com.newrelic.bootstrap.BootstrapLoader.load(BootstrapLoader.java:135)
… 8 more

Hi, @santhoshkumar.m: The error is, “No such file or directory”. How are you specifying the location of the New Relic agent?

@philweber : Thanks for your response ,
$JAVA_OPTS
-javaagent:$CARBON_HOME/newrelic/newrelic.jar
-Dcom.sun.management.jmxremote
-classpath “$CARBON_CLASSPATH” \

PATH = $CARBON_HOME =/home/wso2carbon/wso2is-5.11.0

And is newrelic.jar at the specified path: /home/wso2carbon/wso2is-5.11.0/newrelic/newrelic.jar ?

Yes @philweber is it on the same path.

Does the user account running your application have permission to access the agent path?

Yes @philweber it has access to the newrelic.jar to run current user

wso2carbon@wso2-qa-tl-ue1-pod-5754896d5c-qlwdw:~/wso2is-5.11.0/newrelic$ ls -lart
total 16708
-rwxr-xr-x 1 wso2carbon wso2 70883 Nov 17 19:59 THIRD_PARTY_NOTICES.md
-rwxr-xr-x 1 wso2carbon wso2 11357 Nov 17 19:59 LICENSE
-rwxr-xr-x 1 wso2carbon wso2 12711 Nov 17 19:59 newrelic.yml
-rwxr-xr-x 1 wso2carbon wso2 17727 Nov 17 19:59 extension.xsd
-rwxr-xr-x 1 wso2carbon wso2 4488 Nov 17 19:59 extension-example.xml
-rwxr-xr-x 1 wso2carbon wso2 50048 Nov 17 20:01 newrelic-api.jar
-rwxr-xr-x 1 wso2carbon wso2 16677788 Nov 17 20:06 newrelic.jar
-rwxr-xr-x 1 wso2carbon wso2 37710 Nov 17 20:09 newrelic-api-sources.jar
-rwxr-xr-x 1 wso2carbon wso2 204542 Nov 17 20:09 newrelic-api-javadoc.jar
drwxr-xr-x 2 wso2carbon wso2 229 Dec 13 06:24 .
drwxr-xr-x 1 wso2carbon wso2 94 Dec 13 06:43 …

It looks like it is failing trying to create a temp file:

Caused by: java.io.IOException: No such file or directory
at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.base/java.io.File.createTempFile(File.java:2092)

Do you have a temp directory? Does the wso2 user have write access to it?

I see there is some people has got the same kind of the error .
Here it is Relic Solution: Java Agent JARs in the /temp directory

yes @philweber, temp directory has access.

-rw-r–r-- 1 wso2carbon wso2 8290 Dec 15 02:35 README.txt
-rw-r–r-- 1 wso2carbon wso2 108801 Dec 15 02:35 LICENSE.txt
drwxr-xr-x 6 wso2carbon wso2 213 Dec 15 02:35 dbscripts
drwxr-xr-x 3 wso2carbon wso2 4096 Dec 15 02:35 bin
-rw-r–r-- 1 wso2carbon wso2 8530 Dec 15 02:35 release-notes.html
drwxr-xr-x 2 wso2carbon wso2 25 Dec 15 02:35 updates
drwxr-xr-x 3 wso2carbon wso2 23 Dec 15 02:35 resources
drwxr-xr-x 2 wso2carbon wso2 229 Dec 15 02:36 newrelic
drwxr-xr-x 1 root root 40 Dec 15 02:36 …
-rw-r–r-- 1 wso2carbon wso2 100 Dec 15 03:13 wso2carbon.pid
drwxr-xr-x 3 wso2carbon wso2 24 Dec 15 03:13 backup
drwxr-xr-x 1 wso2carbon wso2 20 Dec 15 03:14 lib
drwxr-xr-x 3 wso2carbon wso2 18 Dec 15 03:14 solr
drwxr-xr-x 1 wso2carbon wso2 94 Dec 15 03:14 .
drwxr-xr-x 1 wso2carbon wso2 141 Dec 15 03:14 repository
drwxr-xr-x 6 wso2carbon wso2 214 Dec 15 03:14 tmp

@santhoshkumar.m following up to see if this issue has been involved? Thank you @philweber for your assistance :slight_smile:

This error is commonly encountered when the agent is unable to extract its JARs to a temporary directory as describe over in https://discuss.newrelic.com/t/relic-solution-java-agent-jars-in-the-temp-folder/58924:

The temporary folder that the agent JARS are added to by the agent on startup is controlled by the java.io.tmpdir environment variable. You can find the current value of java.io.tmpdir by executing the following command:

ps -ef | grep java.io.tmpdir

For example, on Tomcat you may get an output similar to:
-Djava.io.tmpdir=/usr/local/tomcat/temp

1 Like