Search code examples
javatomcattomcat8catalinajava-mission-control

Enabling Flight Recorder in Tomcat causes "Error when initializing JFR"


adding -XX:+FlightRecorder to my CATALINA_OPTS causes this error in my catalina.out log:

Error when initializing JFR. JFR will be deactivated.

java.lang.Exception: Unable to create JFR repository directory using base location (/var/cache/tomcat6/temp).
        at oracle.jrockit.jfr.Repository.create(Repository.java:62)
        at oracle.jrockit.jfr.Repository.<init>(Repository.java:26)
        at oracle.jrockit.jfr.JFRImpl.<init>(JFRImpl.java:108)
        at oracle.jrockit.jfr.VMJFR.<init>(VMJFR.java:55)
        at oracle.jrockit.jfr.VMJFR.create(VMJFR.java:393)
        at oracle.jrockit.jfr.JFR.init(JFR.java:91)
Error occurred during initialization of VM
Failed to start tracing backend.

Here are the full CATALINA_OPTS from /usr/share/tomcat8/bin/setenv.sh:

export CATALINA_OPTS="-Dcom.sun.management.jmxremote=true \
              -Dcom.sun.management.jmxremote.port=9090 \
              -Dcom.sun.management.jmxremote.ssl=false \
              -Dcom.sun.management.jmxremote.authenticate=false \
              -Djava.rmi.server.hostname=10.202.210.173 \
              -XX:+UnlockCommercialFeatures -XX:+FlightRecorder"

If I only enable the -XX:+UnlockCommercialFeatures parameter the tomcat instance does not crash, as soon as I enable FlightRecorder though, it crashes. I've tried it with JAVA_OPTS also and I get the same result.

I am just following tutorials on the internet to get Flight Recorder enabled for Tomcat, so I don't really have an idea of what I can be doing wrong. Everything looks right to me.

This is on a 64 bit CentOS 6.4 box, with Tomcat 8.


Solution

  • Flight Recorder tries to create a repository directory to store temporary data while recording.

    The base directory is the directory that the system property java.io.tmpdir points to. For some reason the Java process can't access or create a directory there. Perhaps the Java process doesn't have privileges?