我正在使用
org.eclipse.tycho:tycho-surefire-plugin:4.0.7:test
启动 Eclipse 插件项目的测试套件。
进程在能够运行任何测试之前崩溃。
Windows 上的错误:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:4.0.7:test (default-test) on project org.scala-ide.sdt.core.tests: An unexpected error occurred while launching the test runtime (process returned error code 1 (HRESULT Code 0x1, check for example https://www.hresult.info/ for further details)). Command-line used to launch the sub-process was C:\Users\nicol\Downloads\jdk-17.0.4_windows-x64_bin\jdk-17.0.4\bin\java.exe -Dosgi.noShutdown=false -Dosgi.os=win32 -Dosgi.ws=win32 -Dosgi.arch=x86_64 -Xmx2048m -Dsdtcore.headless -Dsdtcore.notimeouts -DretryFlakyTests=true -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dosgi.classloader.lock=classname -Dosgi.clean=true -Daj.weaving.verbose=true -Dorg.aspectj.osgi.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true -jar C:\Users\nicol\.m2\repository\p2\osgi\bundle\org.eclipse.equinox.launcher\1.6.700.v20240213-1244\org.eclipse.equinox.launcher-1.6.700.v20240213-1244.jar -debug -consolelog -data C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\work\data -install C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\work -configuration C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\work\configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\surefire.properties in working directory C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests -> [Help 1]
Linux 上同样的错误:
Error: Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:4.0.7:test (default-test) on project org.scala-ide.sdt.core.tests: An unexpected error occurred while launching the test runtime (process returned error code 1). Command-line used to launch the sub-process was /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.10-7/x64/bin/java -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 -Xmx2048m -Dsdtcore.headless -Dsdtcore.notimeouts -DretryFlakyTests=true -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dosgi.classloader.lock=classname -Dosgi.clean=true -Daj.weaving.verbose=true -Dorg.aspectj.osgi.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true -jar /home/runner/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.6.700.v20240213-1244/org.eclipse.equinox.launcher-1.6.700.v20240213-1244.jar -data /home/runner/work/scala-ide/scala-ide/org.scala-ide.sdt.core.tests/target/work/data -install /home/runner/work/scala-ide/scala-ide/org.scala-ide.sdt.core.tests/target/work -configuration /home/runner/work/scala-ide/scala-ide/org.scala-ide.sdt.core.tests/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/runner/work/scala-ide/scala-ide/org.scala-ide.sdt.core.tests/target/surefire.properties in working directory /home/runner/work/scala-ide/scala-ide/org.scala-ide.sdt.core.tests -> [Help 1]
我将 pom 缩小到较小,以删除与测试执行无关的部分:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.scala-ide</groupId>
<artifactId>org.scala-ide.sdt.build</artifactId>
<version>4.7.1-SNAPSHOT</version>
<relativePath>../org.scala-ide.sdt.build/pom.xml</relativePath>
</parent>
<artifactId>org.scala-ide.sdt.core.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<testSuite>${project.artifactId}</testSuite>
<testClass>org.scalaide.TestsSuite</testClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>initialize</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
经过谷歌搜索后,我在Github上发现了这个问题由这个one链接,并尝试添加
<useJDK>BREE</useJDK>
,但这没有帮助。
另外,我似乎可能需要工具链配置,所以我创建了这个
~/.m2/toolchains.xml
:
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<id>JavaSE-17</id>
<version>17</version>
</provides>
<configuration>
<jdkHome>C:\Users\nicol\Downloads\jdk-17.0.4_windows-x64_bin\jdk-17.0.4</jdkHome>
</configuration>
</toolchain>
</toolchains>
但是我仍然遇到这个问题。我错过了什么?
具有堆栈跟踪详细信息:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:4.0.7:test (default-test) on project org.scala-ide.sdt.core.tests: An unexpected error occurred while launching the test runtime (process returned error code 1 (HRESULT Code 0x1, check for example https://www.hresult.info/ for further details)). Command-line used to launch the sub-process was C:\Users\nicol\Downloads\jdk-17.0.4_windows-x64_bin\jdk-17.0.4\bin\java.exe -Dosgi.noShutdown=false -Dosgi.os=win32 -Dosgi.ws=win32 -Dosgi.arch=x86_64 -Xmx2048m -Dsdtcore.headless -Dsdtcore.notimeouts -DretryFlakyTests=true -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dosgi.classloader.lock=classname -Dosgi.clean=true -Daj.weaving.verbose=true -Dorg.aspectj.osgi.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true -jar C:\Users\nicol\.m2\repository\p2\osgi\bundle\org.eclipse.equinox.launcher\1.6.700.v20240213-1244\org.eclipse.equinox.launcher-1.6.700.v20240213-1244.jar -debug -consolelog -data C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\work\data -install C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\work -configuration C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\work\configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\surefire.properties in working directory C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)
Caused by: org.apache.maven.plugin.MojoFailureException: An unexpected error occurred while launching the test runtime (process returned error code 1 (HRESULT Code 0x1, check for example https://www.hresult.info/ for further details)). Command-line used to launch the sub-process was C:\Users\nicol\Downloads\jdk-17.0.4_windows-x64_bin\jdk-17.0.4\bin\java.exe -Dosgi.noShutdown=false -Dosgi.os=win32 -Dosgi.ws=win32 -Dosgi.arch=x86_64 -Xmx2048m -Dsdtcore.headless -Dsdtcore.notimeouts -DretryFlakyTests=true -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dosgi.classloader.lock=classname -Dosgi.clean=true -Daj.weaving.verbose=true -Dorg.aspectj.osgi.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true -jar C:\Users\nicol\.m2\repository\p2\osgi\bundle\org.eclipse.equinox.launcher\1.6.700.v20240213-1244\org.eclipse.equinox.launcher-1.6.700.v20240213-1244.jar -debug -consolelog -data C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\work\data -install C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\work -configuration C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\work\configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests\target\surefire.properties in working directory C:\Users\nicol\git\scala-ide\org.scala-ide.sdt.core.tests
at org.eclipse.tycho.surefire.AbstractEclipseTestMojo.runTest (AbstractEclipseTestMojo.java:1054)
at org.eclipse.tycho.surefire.AbstractEclipseTestMojo.runTests (AbstractEclipseTestMojo.java:639)
at org.eclipse.tycho.surefire.AbstractTestMojo.execute (AbstractTestMojo.java:233)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)
原因是不支持的 jvm 参数:
-XX:+UnsyncloadClass
即使在调试模式(-e -X)下,错误也不会输出到控制台。 必须单独运行java命令才能看到错误:
Unrecognized VM option 'UnsyncloadClass'