[Java] Agents after 5.13.0 do not support Trace annotation and New Relic class anymore?

Hi there,

Maybe kind of a simple question, but I cannot find any answers in new relic documentation or release notes… We used to use java agent 5.13.0 in our spring boot application, and used the @Trace annotation and the NewRelic class (its static methods). Both resided in com.newrelic.api.agent package.

I cannot find any of this in in java agent 5.14.0 and higher (we like to use 6.2.1 or even 6.3.0). So i got compilation errors… help!

What do I miss here?

Thanks | WE

Hey w.everse and welcome to the New Relic Explorers Hub,

To use the New Relic API, you have to make sure to add the newrelic-api.jar to the classpath of your application. Also, make sure that it’s the same version number as the agent you’re using. Everything should be packaged in the zip file you download from New Relic.

For more details go to: Guide to using the Java agent API

2 Likes

Thanks for your reply, but already read that and tried that. We add the agent jar using maven in an automated process, we don’t want to download it manually. In 5.13.0 everything was all present and usable via maven, since 5.14 the classes disappeared from the artifact. Any explanation and resolution for this?

Are you making sure to update the version number of the newrelic-api.jar in your pom.xml when you update the agent as well?

1 Like

We download the agent artifact using pom en copy it later on to the docker using the maven dependency plugin so it is the same artifact… So always the same. This worked perfectly for 5.13.0 but stopped working after that version since the artifacts starting with 5.14.0 do not contain those classes anymore (e.g. @Trace annotation and the static class ‘NewRelic’ and more)

Could you possibly post the pom.xml you’re using when you try to update the agent?

1 Like

@w.everse This has to be an issue with project configuration that is causing the API jar to not be correctly added to the classpath as @rtaylor1 mentioned.

I can confirm that the classes are still available in the API and that we haven’t modified the API recently.

Here’s a very simple project showing usage of the APIs in 6.2.0:

And here’s the build.gradle dependency:

dependencies {
    compile group: 'com.newrelic.agent.java', name: 'newrelic-api', version: '6.2.0'
}
2 Likes

Thank you all! I found the exact cause. Thanks @rtaylor1 and @jkeller for leading me to the cause! Let me explain: up to and including 5.13.0 the api and the agent were combined in 1 jar! So starting with 5.14.0 I have to seperately add the newrelic-api artifact. Couldn’t find that change in the docs!