Java 将VisualVM与Maven Cargo一起使用
我们使用Maven Cargo在本地启动服务并对其运行测试。以下是插件的配置:Java 将VisualVM与Maven Cargo一起使用,java,jmx,visualvm,maven-cargo,Java,Jmx,Visualvm,Maven Cargo,我们使用Maven Cargo在本地启动服务并对其运行测试。以下是插件的配置: <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.6.8</ver
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.8</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<zipUrlInstaller>
<url>
https://www.someurl.com/tosome.zip
</url>
</zipUrlInstaller>
<dependencies>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<!--<classpath>shared</classpath>-->
</dependency>
</dependencies>
</container>
<configuration>
<configfiles>
<configfile>
<file>${project.build.testOutputDirectory}/tomcat-conf/context.xml</file>
<todir>conf</todir>
<tofile>context.xml</tofile>
</configfile>
</configfiles>
<files>
<file>
<file>${project.build.testOutputDirectory}/extra-classpath</file>
<todir>shared/classes</todir>
</file>
</files>
<properties>
<cargo.start.jvmargs>
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=1099
<!-- -Xdebug-->
<!-- -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000-->
<!-- -Xnoagent-->
<!-- -Djava.compiler=NONE-->
</cargo.start.jvmargs>
<cargo.servlet.port>${maven.tomcat.port}</cargo.servlet.port>
<cargo.tomcat.ajp.port>${cargo.tomcat.ajp.port}</cargo.tomcat.ajp.port>
<cargo.rmi.port>${cargo.rmi.port}</cargo.rmi.port>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>our.stuff</groupId>
<artifactId>our-artifact</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
org.codehaus.cargo
在这两种情况下,本地Tomcat服务器正常启动,并像往常一样等待8080上的请求。但是,该过程不会出现在VisualVM应用程序的Local
列表中
我尝试了使用和不使用
中的多个-Dcom.sun.management.jmxremote
参数
我还尝试通过右键单击Local
项目并选择addjmx connection
并输入货物的端口值(1099
),在本地添加连接:
但什么也没发生
精确性:我对VisualVM非常陌生,对所有这些东西不是100%肯定。特别是选择“JMX”。
当您运行启动Cargo
的Maven
命令时,您将得到两个新进程。在上图中,它是ApacheMaven(pid 22512)
和Tomcat(pid 14080)(注意:pid是不相关的,在您的机器上很可能会有所不同)
由于我们的Cargo
被配置为使用Tomcat
,因此我们希望分析Tomcat进程
我以前注意到并尝试过,但是VisualVM
应用程序没有响应,因此我开始探索其他可能性。此外,我第二次尝试这样做,让探查器完全初始化自己,结果几分钟内没有响应