有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java获取异常“org.apache.maven.surefire.booter.SurefireBooterWorkException:.VM崩溃或调用System.exit?”

我正在从事一个基于Maven Cucumber+TestNg的Selenium自动化项目。在运行时,我得到以下异常不确定,但尝试了所有增加或减少Surefire版本的可能性

启动fork时出错,请检查日志中的输出 进程退出代码:1 组织。阿帕奇。专家当然可以。布特。SureFireBooterWorkException:分叉的VM在没有正确告别的情况下终止。虚拟机崩溃或系统崩溃。你叫出口吗

我在这里浪费了很多时间来解决上述问题,以清除错误,但没有任何结果

所以请给我一个解决方案,我更渴望知道这个解决方案

我的配置: JDK版本:1.8 Maven版本:使用3.5.4、3.6.3进行了尝试 Surefire版本:尝试使用较低版本2.18、2.19、2.22.0、2.22.2,目前为3.0.0-M2

我的Pom如下所示

4.0.0 罗尔 罗尔 0.0.1-快照 罐子

<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <aspectj.version>1.7.4</aspectj.version>
    <allure.version>1.4.22</allure.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.surefire.verion>3.0.0-M2</maven.surefire.verion>
    <io.cucumber.verion>4.2.1</io.cucumber.verion>

</properties>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
            <!-- <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> 
                <fork>true</fork> <executable>C:\Program Files\Java\jdk1.8.0_191\bin\javac</executable> 
                </configuration> -->
        </plugin>
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/target/test-classes</outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/resources</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M2</version>

            <configuration>
                                    
                        
                <systemPropertyVariables>
                    <propertyName>java.library.path</propertyName>
                    <buildDirectory>src/main/resources/configFile</buildDirectory>

                </systemPropertyVariables>
                <testFailureIgnore>true</testFailureIgnore>
                <argLine>
                    -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                </argLine>
                <properties>
                    <property>
                        <name>dataproviderthreadcount</name>
                        <value>2</value>
                    </property>
                </properties>
                <suiteXmlFiles>
                    com.hal.online
                    <suiteXmlFile>src/test/java/com/hal/online/test/testng/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.10.v20150310</version>
        </plugin>
        <!-- <plugin> <groupId>ch.fortysix</groupId> <artifactId>maven-postman-plugin</artifactId> 
            <version>0.1.6</version> <executions> <execution> <id>send_an_email</id> 
            <phase>test</phase> <goals> <goal>send-mail</goal> </goals> <inherited>false</inherited> 
            <configuration> <mailhost>smtp.gmail.com</mailhost> <mailport>465</mailport> 
            <mailauth>true</mailauth> <mailssl>true</mailssl> <mailAltConfig>true</mailAltConfig> 
            <mailuser>test12@gmail.com</mailuser> <mailpassword>test@123</mailpassword> 
            <from>test12@gmail.com</from> <subject>E-commerce Automation Report 
            </subject> <failonerror>true</failonerror> <htmlMessage> <![CDATA[ <p>Hi,</p> 
            <p>Check out the attached test execution report.</p> <p>From,</p> <p>Test  
            user</p> <p>UVS Automation Team</p> ]]> </htmlMessage> <receivers> <receiver>tetuser12@gmail.com</receiver> 
            <receiver>test12@gmail.com</receiver> </receivers> <fileSets> <fileSet> 
            <directory>${basedir}/Automation_Report/Reports</directory> <includes> <include>**/Report.html</include> 
            </includes> </fileSet> </fileSets> </configuration> </execution> </executions> 
            </plugin> -->
    </plugins>
</build>

<dependencies>
    <!--Cucumber Dependencies -->


    <!-- cucumber-java -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <!-- <version>${io.cucumber.verion}</version> -->
        <version>4.2.1</version>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-jvm</artifactId>
        <!-- <version>5.1.0</version> -->
        <version>4.2.1</version>
        <type>pom</type>
    </dependency>

    <!--cucumber-jvm-deps <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-jvm-deps</artifactId> 
        <version>1.0.6</version> </dependency> -->

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <!-- <version>5.1.0</version> -->
        <version>4.2.1</version>
        <!-- <version>1.2.6</version> -->
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-gherkin</artifactId>
        <!-- <version>3.2.0</version> -->
        <version>5.1.0</version>
    </dependency>

    <!-- cucumber-testng -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-testng</artifactId>
        <!-- <version>${io.cucumber.verion}</version> -->
        <version>4.2.1</version>
    </dependency>

    <!-- cucumber-picocontainer -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>${io.cucumber.verion}</version>
    </dependency>



    <!-- https://mvnrepository.com/artifact/org.json/json -->
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20180813</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>4.1.2</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
    <!-- <dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> 
        <version>1.1.1</version> </dependency> -->



    <!-- Logging -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>

    <!-- Extent Reports -->
    <!-- <dependency> <groupId>com.vimalselvam</groupId> <artifactId>cucumber-extentsreport</artifactId> 
        <version>3.0.2</version> </dependency> <dependency> <groupId>com.aventstack</groupId> 
        <artifactId>extentreports</artifactId> <version>3.1.2</version> </dependency> 
        <dependency> <groupId>com.relevantcodes</groupId> <artifactId>extentreports</artifactId> 
        <version>2.41.1</version> </dependency> -->

    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports</artifactId>
        <version>4.0.9</version>
    </dependency>
    <!-- extentreports-cucumber4-adapter -->
    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports-cucumber4-adapter</artifactId>
        <version>1.0.8</version>
    </dependency>

    <!-- Testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-testng -->
    <dependency>
        <groupId>org.apache.maven.surefire</groupId>
        <artifactId>surefire-testng</artifactId>
        <version>3.0.0-M2</version>
    </dependency>



    <!-- Selenium -->
    <!-- io.github.bonigarcia webdrivermanager -->

    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>3.5.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.141.59</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>4.0.0-alpha-4</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.paulhammant/ngwebdriver -->
    <dependency>
        <groupId>com.paulhammant</groupId>
        <artifactId>ngwebdriver</artifactId>
        <version>1.1.4</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-htmlunit-driver</artifactId>
        <version>2.52.0</version>
    </dependency>
    <!-- org.sikuli/sikuli-api -->
    <dependency>
        <groupId>org.sikuli</groupId>
        <artifactId>sikuli-api</artifactId>
        <version>1.2.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.10.1</version>
    </dependency>

    <!-- rest-assured-io -->
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>3.3.0</version>
    </dependency>
    <!-- SQL SERVER JDBC DRIVER -->
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>7.2.1.jre8</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.fusesource.jansi/jansi -->

</dependencies>
<name>ROL</name>

控制台输出

[INFO]  T E S T S
[INFO] -------------------------------------------------------
[WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM 1. See FAQ web page and the dump file D:\JDA_Project\target\surefire-reports\2020-06-30T16-57-34_744-jvmRun1.dumpstream
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[ERROR] There are test failures.

Please refer to D:\JDA_Project\target\surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_251\jre\bin\java" -javaagent:C:\Users\XXXX\.m2\repository/org/aspectj/aspectjweaver/1.7.4/aspectjweaver-1.7.4.jar -jar "C:\Users\Balaji SIngh\AppData\Local\Temp\surefire1099821871492178220\surefirebooter6557031630400864690.jar" "C:\Users\xxxx\AppData\Local\Temp\surefire1099821871492178220" 2020-06-30T16-57-34_744-jvmRun1 surefire5334753707605775945tmp surefire_08619917104831991186tmp"
Error occurred in starting fork, check output in log
Process Exit Code: 1
org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_251\jre\bin\java" -javaagent:C:\Users\xxxx\.m2\repository/org/aspectj/aspectjweaver/1.7.4/aspectjweaver-1.7.4.jar -jar "C:\Users\xxxx \AppData\Local\Temp\surefire1099821871492178220\surefirebooter6557031630400864690.jar" "C:\Users\xxxx\AppData\Local\Temp\surefire1099821871492178220" 2020-06-30T16-57-34_744-jvmRun1 surefire5334753707605775945tmp surefire_08619917104831991186tmp"
Error occurred in starting fork, check output in log
Process Exit Code: 1
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:670)
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1159)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1000)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:846)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.996 s
[INFO] Finished at: 2020-06-30T16:57:35+05:30
[INFO] Final Memory: 41M/398M

共 (2) 个答案

  1. # 1 楼答案

    在我的例子中,我的用户配置文件有问题,中间有空格

    已经解决了我的问题,现在工作正常。这个问题与我的档案名称有关,档案名称之间有空格,因此通过删除空格来更改档案名称,之后即使是较低版本的surefire,其最新版本也可以正常工作

    The User profile can be found under C:/Users/<userprofile>
    
    Changed my Profile user name from"Balaji Singh" to "BalajiSingh" and with updation on surefire version in  pom everything started working.
    
        [INFO]                            -
        [INFO]  T E S T S
        [INFO]                            -
        [INFO] Running TestSuite
        chrome
        2020-07-10 11:05:59 [INFO ] [InitializeWebDrive] - [standAloneStepUp] CHROME
        Starting ChromeDriver 2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5) on port 10704
        Only local connections are allowed.
        [1594359363.546][WARNING]: Timed out connecting to Chrome, retrying...
        Jul 10, 2020 11:06:05 AM org.openqa.selenium.remote.ProtocolHandshake createSession
        INFO: Detected dialect: OSS
        [1594359367.679][WARNING]: Timed out connecting to Chrome, retrying...
        chrome
        2020-07-10 11:06:09 [INFO ] [InitializeWebDrive] - [before] CHROME
        ChromeDriver: chrome on XP (c79a5836b92a01f0250044d972add9af)
        *****************************
        ROL home page should be visible
        currently system is on ROL entry home page
        navigated to ShipmentEntry page successfully
        1 Scenarios (1 passed)
        21 Steps (21 passed)
        2m55.358s
        
        [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 176.404 s - in TestSuite
        [INFO] 
        [INFO] Results:
        [INFO] 
        [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
        [INFO] 
        [INFO]                                     
        [INFO] BUILD SUCCESS
        [INFO]                                     
        [INFO] Total time: 03:04 min
        [INFO] Finished at: 2020-07-10T11:08:54+05:30
        [INFO] Final Memory: 42M/398M
        [INFO]                                     
    
  2. # 2 楼答案

    请务必使用最新版本进行检查。目前是3.0.0-M5