As part of my build, we use cargo-maven2-plugin to launch a jetty container with our app. Intermittently, we get the result "Failed to start the Jetty 6.x Embedded container." We're bumping up against the default 120 second timeout.
We're using a Sun 1.6.0_07 JVM, so I thought that hprof might be able to help.
As a sanity test, I started with
set MAVEN_OPTS=%MAVEN_OPTS% -agentlib:hprof=cpu=samples,interval=20,depth=3,file=hprof.out
and then ran
mvn -Dmaven.test.skip=true install
(Cargo is configured to run during the pre-integration-test and post-integration-test goals)
This appears to be what I want - I see the messages for starting and stopping the container, and messages that the tests are being skipped. After maven outputs the build summary, I see the message "Dumping CPI usage by sampling running threads ... done." The hprof.out file is written, it has the kind of sample data I want.
Of course, this is a sampling of maven itself, which isn't useful.
How do I get that same sampling information for my web app?
My initial thought was to use the cargo.jvmargs property
<cargo.jvmargs>-agentlib:hprof=cpu=samples,interval=20,depth=3,file=hprof.out</cargo.jvmargs>
, but (a) when I do this (removing the profiling arguments from MAVEN_OPTS), I can't find a resulting hprof.out file and (b) a second look at the documentation suggests that maybe those are only used for the start/stop of the container, and not the container itself?