Athens Holloway
Athens Holloway

Reputation: 2203

Heroku New Relic Add-on for Java App fails to open newrelic.jar

I downloaded New Relic 2.12.0 and configured it according to the Heroku java configuration documentation.

I unzipped the package contents to the root of my spring mvc application directory as indicated in the following image

enter image description here

Next, I pushed the new files to Heroku:

$ git add newrelic
$ git commit -m 'add newrelic'
$ git push heroku master

Finally, I bootstrapped the new relic agent:

$ heroku config:add JAVA_OPTS='-Xmx384m -Xss512k -XX:+UseCompressedOops -javaagent:newrelic/newrelic.jar'

Afterwards, my application failed with the following error and appears to not be able to locate the newrelic.jar file.

The new relic documentation says the JVM args (e.g. -javaagent:newrelic/newrelic.jar) should include the full path to the newrelic.jar file, but according the the Heroku documentation, -javaagent:newrelic/newrelic.jar is all that's needed.

2013-01-15T19:41:11+00:00 heroku[web.1]: Starting process with command `java -Xmx384m -Xss512k -XX:+UseCompressedOops -javaagent:newrelic/newrelic.jar -Dspring.profiles.active=prod -jar target/dependency/webapp-runner.jar --port 47412 target/*.war`
2013-01-15T19:41:11+00:00 app[web.1]: agent library failed to init: instrument
2013-01-15T19:41:11+00:00 app[web.1]: Error occurred during initialization of VM
2013-01-15T19:41:11+00:00 app[web.1]: Error opening zip file or JAR manifest missing : newrelic/newrelic.jar
2013-01-15T19:41:12+00:00 heroku[web.1]: Process exited with status 1
2013-01-15T19:41:12+00:00 heroku[web.1]: State changed from starting to crashed

UPDATE

After checking the newrelic directory on my web dyno, I noticed the jar file was missing. Now I am looking into the cause of the missing jar file.

enter image description here

Update

The .gitignore file in the root of my application directory excludes jar files which prevents the newrelic.jar file from being deployed.

<<<<<<< HEAD
/target
/.classpath
/.project
/.settings
/tomcat.*
/.idea
/*.iml
=======
*.class

# Package Files #
*.jar
*.war
*.ear

Upvotes: 0

Views: 1888

Answers (2)

noBillSide
noBillSide

Reputation: 528

Had the same problem with the missing jar file in the target/dependency folder .

For me the problem was the pom file (provided by the Heroku example)

Here is my working POM:

                <executions>
                 <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.eclipse.jetty</groupId>
                                <artifactId>jetty-runner</artifactId>
                                <version>9.2.3.v20140905</version>
                                <destFileName>jetty-runner.jar</destFileName>
                            </artifactItem>
                            <artifactItem>
                                <groupId>com.newrelic.agent.java</groupId>
                                <artifactId>newrelic-agent</artifactId>
                                <version>3.12.0</version>
                                <destFileName>newrelic-agent.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                  </execution>
                </executions>

And for sure also add New Relic as dependency...

        <dependency>
           <groupId>com.newrelic.agent.java</groupId>
           <artifactId>newrelic-api</artifactId>
           <version>3.12.0</version>
        </dependency>

Upvotes: 0

Thom
Thom

Reputation: 2493

Is it possible you've left something in your .gitignore file that ignores jars? If you heroku run bash and then ls newrelic do you see the jars in there?

Upvotes: 3

Related Questions