How to set java agent path in heroku procfile?

In my heroku procfile i have already add java agent path like this
web: java -javaagent:newrelic/newrelic.jar

But i’m getting following error :

        app/web.1: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
 app/web.1: Picked up JAVA_TOOL_OPTIONS: -Xmx671m -XX:CICompilerCount=2 -Dfile.encoding=UTF-8 
 app/web.1: Jun 29, 2020 11:38:27 +0000 [4 1] com.newrelic INFO: New Relic Agent: Loading configuration file "/app/newrelic/./newrelic.yml"
 app/web.1: Jun 29, 2020 11:38:27 +0000 [4 1] com.newrelic INFO: Using default collector host: collector.newrelic.com
 app/web.1: Jun 29, 2020 11:38:28 +0000 [4 1] com.newrelic INFO: New Relic Agent v5.13.0 is initializing...
 app/web.1: Jun 29, 2020 11:38:30 +0000 [4 11] com.newrelic INFO: Instrumentation com.newrelic.instrumentation.jdbc-resultset is disabled. Skipping.
 app/web.1: Jun 29, 2020 11:38:35 +0000 [4 1] com.newrelic.agent.RPMServiceManagerImpl INFO: Configured to connect to New Relic at collector.newrelic.com:443
 app/web.1: Jun 29, 2020 11:38:36 +0000 [4 1] com.newrelic INFO: Setting audit_mode to false
 app/web.1: Jun 29, 2020 11:38:36 +0000 [4 1] com.newrelic INFO: Setting protocol to "https"
 app/web.1: Jun 29, 2020 11:38:36 +0000 [4 1] com.newrelic INFO: Agent class loader: com.newrelic.bootstrap.BootstrapAgent$JVMAgentClassLoader@25f38edc
 app/web.1: Jun 29, 2020 11:38:36 +0000 [4 1] com.newrelic INFO: Premain startup complete in 10,888ms
 app/web.1: Usage: java [-options] class [args...]
 app/web.1:            (to execute a class)
 app/web.1: where options include:
 app/web.1:     -d32	  use a 32-bit data model if available
 app/web.1:     -d64	  use a 64-bit data model if available
 app/web.1:     -server	  to select the "server" VM
 app/web.1:                   because you are running on a server-class machine.
 app/web.1: 
 app/web.1: 
 app/web.1:     -cp <class search path of directories and zip/jar files>
 app/web.1:     -classpath <class search path of directories and zip/jar files>
 app/web.1:                   A : separated list of directories, JAR archives,
 app/web.1:                   and ZIP archives to search for class files.
 app/web.1:     -D<name>=<value>
 app/web.1:                   set a system property
 app/web.1:     -verbose:[class|gc|jni]
 app/web.1:                   enable verbose output
 app/web.1:     -version      print product version and exit
 app/web.1:     -version:<value>
 app/web.1: Jun 29, 2020 11:38:37 +0000 [4 6] com.newrelic.agent.core.CoreServiceImpl INFO: JVM is shutting down
 app/web.1: Jun 29, 2020 11:38:37 +0000 [4 6] com.newrelic.agent.core.CoreServiceImpl INFO: New Relic Agent has shutdown
 heroku/web.1: State changed from starting to crashed

Hello @dharmesh.vekariya, thank you for reaching out. I see the agent is getting shutdown gracefully, could be because it is getting a shutdown request from the JVM. Have you followed all the steps to configure the agent as well as Heroku from the document here: https://docs.newrelic.com/docs/agents/java-agent/heroku/java-agent-heroku?

Also, is the path to the newrelic.jar correct? I see you are passing java -javaagent:newrelic/newrelic.jar can it be java -javaagent:/newrelic/newrelic.jar?

Thanks

@mlavania thank you for your reply :blush:

yes @mlavania the path of newrelic.jar is correct.

in the application root folder, I have create newrelic folder and unzip the newrelic-java-5.13.0.zip file in this folder.

yes, @mlavania I followed all the steps to configure the java agent as well as Heroku.


@mlavania could you explain to me what is meaning of -jar target/HELLOWORLD.jar ?
could i need to add in the Procfile ?

Note: my application generates a war file, not a jar file. so can I need to convert jar to war file?

Hi Dharmesh!

I see Madhav has pointed out some steps on deploying to Heroku, but turns out you are using a WAR file. I found some steps to deploy WAR files on Heroku: Configuring WAR deployment with Heroku Toolbelt:

$ heroku war:deploy myapp.war --includes newrelic.jar:newrelic.xml

That said, Heroku Support may be a good resource for this questioon. Have you tried reaching out to Heroku Support as well?

Cheers!

1 Like