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

你离开我真会死。 提交于 2019-12-08 04:00:37

问题


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?


回答1:


If you are using jcmd command from jdk, then could enable JFR via:

jcmd 31118 VM.unlock_commercial_features

Then use JFR.

e.g

jcmd 31118 JFR.start name=a




回答2:


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




回答3:


I got the answer by using below.

export MAVEN_OPTS="$MAVEN_OPTS -XX:+UnlockCommercialFeatures -XX:+FlightRecorder"


来源:https://stackoverflow.com/questions/25518834/how-to-add-enable-flag-for-flight-recorder-in-maven-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!