将visualvm与maven cargo结合使用

hujrc8aj  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(358)

我们使用maven cargo在本地启动服务并对其运行测试。以下是插件的配置:

<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>

我们使用以下命令发射货物: clean prepare-package cargo:run -Dcargo.tomcat.ajp.port=9080 -Dmaven.tomcat.port=8080 -Dcargo.rmi.port=9070 我试过用普通的intellij run按钮和visualvm启动程序启动进程:

在这两种情况下,本地tomcat服务器正常启动,并像往常一样等待8080上的请求。然而,这个过程并没有出现在 Local 在visualvm应用程序中列出。
我试过有没有多重的 -Dcom.sun.management.jmxremote 中的args <cargo.start.jvmargs> .
我还尝试通过右键单击 Local 项目和选择 Add JMX Connection 输入货物的港口价值( 1099 ):


但什么也没发生。
精确性:我对visualvm非常陌生,对所有这些东西不是百分之百肯定。特别是选择“jmx”。

igetnqfo

igetnqfo1#


当你跑步的时候 Maven 启动 Cargo ,您将得到两个新进程。在上图中,它是 Apache Maven (pid 22512) 以及 Tomcat (pid 14080) (注意:PID是不相关的,在您的机器上很可能是不同的)。
自从我们 Cargo 配置为使用 Tomcat ,tomcat进程就是我们想要分析的进程。
我以前注意到并尝试过,但是 VisualVM 申请者React迟钝,于是我开始探索其他的可能性。而且,第二次我试着让 Profiler 完全初始化,这东西有几分钟没有React。

相关问题