Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将VisualVM与Maven Cargo一起使用_Java_Jmx_Visualvm_Maven Cargo - Fatal编程技术网

Java 将VisualVM与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

我们使用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>

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
应用程序没有响应,因此我开始探索其他可能性。此外,我第二次尝试这样做,让
探查器完全初始化自己,结果几分钟内没有响应