Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add enable flag for Flight Recorder in Maven project?

Tags:

flags

maven

jmc

jfr

I'm just about start using Java Mission Control 5.3.0.

I have added -XX:+UnlockCommercialFeatures -XX:+FlightRecorder into my web-app's jetty.template.

Then I start the web-app with mvn jetty:run.

But while I was starting Flight Recorder I got the problem occurred pop-up as below.

'Start Flight Recording.. (Last attempt failed)' have encountered a problem.Commercial features are not enabled. In JDK7u4 and above,the JVM must be started with -XX:+UnlockCommercialFeatures -XX:+FlightRecorder .

And I also try adding the flags as below into pom.xml but it doesn't work.

<jvmArgs>
    <jvmArg>-Xmx128m</jvmArg>
    <jvmArg>-Xms128m</jvmArg>
    <jvmArg>-XX:MaxPermSize=512m</jvmArg>
    <jvmArg>-XX:+UnlockCommercialFeatures</jvmArg>
    <jvmArg>-XX:+FlightRecorder</jvmArg>
    <jvmArg>-XX:StartFlightRecording=duration=160s,delay=20s,settings=profile,filename=target/recording.jfr</jvmArg>
</jvmArgs>

What should I do for enable Flight Recorder on my web-app?

like image 793
phantipa Avatar asked Sep 07 '25 13:09

phantipa


2 Answers

That configuration should be added to the running VM of Jetty so I'd try this:

mvn jetty:run -XX:+UnlockCommercialFeatures -XX:+FlightRecorder

I could not test this, and I work most on Tomcat, but I think this could help you

like image 161
earroyoron Avatar answered Sep 09 '25 02:09

earroyoron


I got the answer by using below.

export MAVEN_OPTS="$MAVEN_OPTS -XX:+UnlockCommercialFeatures -XX:+FlightRecorder"
like image 43
phantipa Avatar answered Sep 09 '25 01:09

phantipa