Adding java agent on Tomcat 8

I am having trouble adding the Java agent to Tomcat 8 running in docker. This is the exception I get:

Error opening zip file or JAR manifest missing : /usr/local/tomcat/apm/elastic-apm-agent-1.16.0.jar
Error occurred during initialization of VM
agent library failed to init: instrument

I have checked that the jar file is there and have read permissions.
It is the same error I get if I remove the file, so clearly the file is not visible by Tomcat.

This is my file:
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/usr/local/tomcat/apm/elastic-apm-agent-1.16.0.jar"

This is from my Dockerfile:

ADD ./lib/elastic-apm-agent-1.16.0.jar /usr/local/tomcat/apm/elastic-apm-agent-1.16.0.jar
ADD ./lib/ /usr/local/tomcat/bin/
RUN chmod +x /usr/local/tomcat/bin/

It is running tomcat:8.5 (Have tried multiple images)

I am really stuck, so any help would be great.

Hi @Danny_Larsen,

This error message usually indicates that the agent jar file is not readable by the JVM process.

Could you add the following lines to your file and send us the output ?

echo $USER # prints user name running tomcat
ls -ahl /usr/local/tomcat/apm/elastic-apm-agent-1.16.0.jar # check file permissions
sha1sum /usr/local/tomcat/apm/elastic-apm-agent-1.16.0.jar # check file integrity

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.