Search code examples
spring-bootgradlebuild.gradlenewrelicjib

java agent fails to start with jib created image for a springboot app. [agent library failed to init: instrument]


I have a spring-boot project with the following structure

enter image description here

I am using gradle and using the jib plugin to build my docker image.

jib plugin version:

id 'com.google.cloud.tools.jib' version '3.1.2'

I am using the jib plugin to copy all contents of the newrelic folder into the /app/libs/newrelic folder then later setting it as the java agent on line 131.

The problem is when I build this image with jib 'jibDockerBuild', the process is successful, the files seem to be copied but when I start start any container from this image, I get an error

Error opening zip file or JAR manifest missing : /app/libs/newrelic/newrelic.jar
Error occurred during initialization of VM
agent library failed to init: instrument

I have tred to look at the files in the container and this path exists and the jar also exists in the directory:

using docker export -o dump.tar 13a92d2f193d

then tar -tvf dump.tar

I can see the files in the container :

enter image description here

Could there be something I am missing in the setup?


Solution

  • The screenshot shows that the size of /app/libs/newrelic/newrelic.jar is zero. Check the JAR file on your local filesystem and make sure that you have a valid one.