切换到 Java11 后无法执行目标 org.eclipse.tycho:tycho-surefire-plugin:2.0.0:test (default-test)
Can't execute goal org.eclipse.tycho:tycho-surefire-plugin:2.0.0:test (default-test) after switching to Java11
我正在尝试将我们遗留的基于 eclipse-plugin 的多模块项目切换到 Java-11,并且几乎完成了所有项目,除了“eclipse-test-plugin”项目。他们都抛出类似的错误
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.osgi.internal.baseadaptor.BaseStorage (file:/home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.osgi/3.9.1.v20140110-1610/org.eclipse.osgi-3.9.1.v20140110-1610.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of org.eclipse.osgi.internal.baseadaptor.BaseStorage
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
An error has occurred. See the log file
/home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration/1599554461428.log.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.877 s
[INFO] Finished at: 2020-09-08T04:41:01-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:2.0.0:test (default-test) on project TEST-PROJECT: An unexpected error occurred while launching the test runtime (process returned error code 13). Command-line used to launch the sub-process was null -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 --illegal-access=permit -Dosgi.clean=true -jar /home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.3.0.v20130327-1440/org.eclipse.equinox.launcher-1.3.0.v20130327-1440.jar -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -install /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work -configuration /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties in working directory /home/USER/projects/java/PATH-TO-TEST-PROJECT -> [Help 1]
这是日志文件
!SESSION 2020-09-08 04:41:01.199 -----------------------------------------------
eclipse.buildId=unknown
java.version=11.0.7
java.vendor=AdoptOpenJDK
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties
Command-line arguments: -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties
!ENTRY org.eclipse.osgi 4 0 2020-09-08 04:41:01.829
!MESSAGE Startup error
!STACK 1
java.lang.RuntimeException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:233)
at org.eclipse.osgi.framework.internal.core.Framework.launch(Framework.java:656)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:275)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:225)
... 11 more
Caused by: java.lang.IllegalStateException: The System Bundle could not be resolved: Missing Constraint: Bundle-RequiredExecutionEnvironment: J2SE-1.5
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.checkSystemState(BaseStorage.java:827)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.getStateManager(BaseStorage.java:800)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.getState(BaseAdaptor.java:387)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.frameworkStart(BaseStorage.java:923)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.frameworkStart(BaseAdaptor.java:250)
at org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start(SystemBundleActivator.java:60)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.run(BundleContextImpl.java:711)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 13 more
MANIFEST.MF 长得像
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: PROJECT Test
Bundle-SymbolicName: TEST-PROJECT
Bundle-Version: 2.1.2
Bundle-Vendor: VENDOR
Fragment-Host: PROJECT-WHICH-IS-TESTED
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: org.junit
Require-Bundle: org.junit
Automatic-Module-Name: TEST-PROJECT
这是带有 tycho-surefire-plugin 的父 pom
<pluginManagement>
...
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<aggregate>true</aggregate>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
</plugins>
</pluginManagement>
这是测试项目的 pom
...
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<testSuite>${project.artifactId}</testSuite>
<testClass>${project.artifactId}.suite.TestSuite</testClass>
</configuration>
</plugin>
</plugins>
</build>
...
如果运行 mvn clean install -X -e 那么我会得到
!ENTRY org.eclipse.osgi 4 0 2020-09-08 03:11:41.320
!MESSAGE Startup error
!STACK 1
java.lang.RuntimeException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:233)
at org.eclipse.osgi.framework.internal.core.Framework.launch(Framework.java:656)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:275)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:225)
... 11 more
Caused by: java.lang.IllegalStateException: The System Bundle could not be resolved: Missing Constraint: Bundle-RequiredExecutionEnvironment: J2SE-1.5
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.checkSystemState(BaseStorage.java:827)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.getStateManager(BaseStorage.java:800)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.getState(BaseAdaptor.java:387)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.frameworkStart(BaseStorage.java:923)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.frameworkStart(BaseAdaptor.java:250)
at org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start(SystemBundleActivator.java:60)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.run(BundleContextImpl.java:711)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 13 more
An error has occurred. See the log file
/home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration/1599549100674.log.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 49.043 s
[INFO] Finished at: 2020-09-08T03:11:41-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:1.7.0:test (default-test) on project com.navteq.phoenix.datatest.test: An unexpected error occurred while launching the test runtime (process returned error code 13). Command-line used to launch the sub-process was null -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 --illegal-access=permit -Dosgi.clean=true -jar /home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.3.0.v20130327-1440/org.eclipse.equinox.launcher-1.3.0.v20130327-1440.jar -debug -consolelog -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -install /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work -configuration /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties in working directory /home/USER/projects/java/PATH-TO-TEST-PROJECT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:1.7.0:test (default-test) on project com.navteq.phoenix.datatest.test: An unexpected error occurred while launching the test runtime (process returned error code 13). Command-line used to launch the sub-process was null -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 --illegal-access=permit -Dosgi.clean=true -jar /home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.3.0.v20130327-1440/org.eclipse.equinox.launcher-1.3.0.v20130327-1440.jar -debug -consolelog -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -install /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work -configuration /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties in working directory /home/USER/projects/java/PATH-TO-TEST-PROJECT
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: An unexpected error occurred while launching the test runtime (process returned error code 13). Command-line used to launch the sub-process was null -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 --illegal-access=permit -Dosgi.clean=true -jar /home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.3.0.v20130327-1440/org.eclipse.equinox.launcher-1.3.0.v20130327-1440.jar -debug -consolelog -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -install /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work -configuration /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties in working directory /home/USER/projects/java/PATH-TO-TEST-PROJECT
at org.eclipse.tycho.surefire.TestMojo.runTest (TestMojo.java:1093)
at org.eclipse.tycho.surefire.TestMojo.execute (TestMojo.java:712)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
那么有人可以给我一些建议,告诉我在这种情况下我应该怎么做吗?
P.S。早些时候所有 运行 在 Java8 上成功使用 tycho-surefire 0.18.1 和 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
我相信我已经找到问题的主要根源。重点是在我的 parent pom.xml 中设置了一个“Eclipse Kepler”作为存储库。这就是为什么当我使用 JavaSE-1.8 时,surefire 插件按预期工作,但是当我切换到 JavaSE-11 时,“开普勒”被证明是过时的,结果,我得到一个关于
的奇怪错误
Missing Constraint: Bundle-RequiredExecutionEnvironment: J2SE-1.5
改成最新的eclipse repository后,所有测试都编译通过了
我正在尝试将我们遗留的基于 eclipse-plugin 的多模块项目切换到 Java-11,并且几乎完成了所有项目,除了“eclipse-test-plugin”项目。他们都抛出类似的错误
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.osgi.internal.baseadaptor.BaseStorage (file:/home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.osgi/3.9.1.v20140110-1610/org.eclipse.osgi-3.9.1.v20140110-1610.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of org.eclipse.osgi.internal.baseadaptor.BaseStorage
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
An error has occurred. See the log file
/home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration/1599554461428.log.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.877 s
[INFO] Finished at: 2020-09-08T04:41:01-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:2.0.0:test (default-test) on project TEST-PROJECT: An unexpected error occurred while launching the test runtime (process returned error code 13). Command-line used to launch the sub-process was null -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 --illegal-access=permit -Dosgi.clean=true -jar /home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.3.0.v20130327-1440/org.eclipse.equinox.launcher-1.3.0.v20130327-1440.jar -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -install /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work -configuration /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties in working directory /home/USER/projects/java/PATH-TO-TEST-PROJECT -> [Help 1]
这是日志文件
!SESSION 2020-09-08 04:41:01.199 -----------------------------------------------
eclipse.buildId=unknown
java.version=11.0.7
java.vendor=AdoptOpenJDK
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties
Command-line arguments: -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties
!ENTRY org.eclipse.osgi 4 0 2020-09-08 04:41:01.829
!MESSAGE Startup error
!STACK 1
java.lang.RuntimeException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:233)
at org.eclipse.osgi.framework.internal.core.Framework.launch(Framework.java:656)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:275)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:225)
... 11 more
Caused by: java.lang.IllegalStateException: The System Bundle could not be resolved: Missing Constraint: Bundle-RequiredExecutionEnvironment: J2SE-1.5
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.checkSystemState(BaseStorage.java:827)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.getStateManager(BaseStorage.java:800)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.getState(BaseAdaptor.java:387)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.frameworkStart(BaseStorage.java:923)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.frameworkStart(BaseAdaptor.java:250)
at org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start(SystemBundleActivator.java:60)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.run(BundleContextImpl.java:711)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 13 more
MANIFEST.MF 长得像
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: PROJECT Test
Bundle-SymbolicName: TEST-PROJECT
Bundle-Version: 2.1.2
Bundle-Vendor: VENDOR
Fragment-Host: PROJECT-WHICH-IS-TESTED
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: org.junit
Require-Bundle: org.junit
Automatic-Module-Name: TEST-PROJECT
这是带有 tycho-surefire-plugin 的父 pom
<pluginManagement>
...
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<aggregate>true</aggregate>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
</plugins>
</pluginManagement>
这是测试项目的 pom
...
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<testSuite>${project.artifactId}</testSuite>
<testClass>${project.artifactId}.suite.TestSuite</testClass>
</configuration>
</plugin>
</plugins>
</build>
...
如果运行 mvn clean install -X -e 那么我会得到
!ENTRY org.eclipse.osgi 4 0 2020-09-08 03:11:41.320
!MESSAGE Startup error
!STACK 1
java.lang.RuntimeException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:233)
at org.eclipse.osgi.framework.internal.core.Framework.launch(Framework.java:656)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:275)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:225)
... 11 more
Caused by: java.lang.IllegalStateException: The System Bundle could not be resolved: Missing Constraint: Bundle-RequiredExecutionEnvironment: J2SE-1.5
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.checkSystemState(BaseStorage.java:827)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.getStateManager(BaseStorage.java:800)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.getState(BaseAdaptor.java:387)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.frameworkStart(BaseStorage.java:923)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.frameworkStart(BaseAdaptor.java:250)
at org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start(SystemBundleActivator.java:60)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.run(BundleContextImpl.java:711)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 13 more
An error has occurred. See the log file
/home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration/1599549100674.log.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 49.043 s
[INFO] Finished at: 2020-09-08T03:11:41-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:1.7.0:test (default-test) on project com.navteq.phoenix.datatest.test: An unexpected error occurred while launching the test runtime (process returned error code 13). Command-line used to launch the sub-process was null -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 --illegal-access=permit -Dosgi.clean=true -jar /home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.3.0.v20130327-1440/org.eclipse.equinox.launcher-1.3.0.v20130327-1440.jar -debug -consolelog -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -install /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work -configuration /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties in working directory /home/USER/projects/java/PATH-TO-TEST-PROJECT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:1.7.0:test (default-test) on project com.navteq.phoenix.datatest.test: An unexpected error occurred while launching the test runtime (process returned error code 13). Command-line used to launch the sub-process was null -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 --illegal-access=permit -Dosgi.clean=true -jar /home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.3.0.v20130327-1440/org.eclipse.equinox.launcher-1.3.0.v20130327-1440.jar -debug -consolelog -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -install /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work -configuration /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties in working directory /home/USER/projects/java/PATH-TO-TEST-PROJECT
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: An unexpected error occurred while launching the test runtime (process returned error code 13). Command-line used to launch the sub-process was null -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 --illegal-access=permit -Dosgi.clean=true -jar /home/USER/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.3.0.v20130327-1440/org.eclipse.equinox.launcher-1.3.0.v20130327-1440.jar -debug -consolelog -data /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/data -install /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work -configuration /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /home/USER/projects/java/PATH-TO-TEST-PROJECT/target/surefire.properties in working directory /home/USER/projects/java/PATH-TO-TEST-PROJECT
at org.eclipse.tycho.surefire.TestMojo.runTest (TestMojo.java:1093)
at org.eclipse.tycho.surefire.TestMojo.execute (TestMojo.java:712)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
那么有人可以给我一些建议,告诉我在这种情况下我应该怎么做吗?
P.S。早些时候所有 运行 在 Java8 上成功使用 tycho-surefire 0.18.1 和 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
我相信我已经找到问题的主要根源。重点是在我的 parent pom.xml 中设置了一个“Eclipse Kepler”作为存储库。这就是为什么当我使用 JavaSE-1.8 时,surefire 插件按预期工作,但是当我切换到 JavaSE-11 时,“开普勒”被证明是过时的,结果,我得到一个关于
的奇怪错误Missing Constraint: Bundle-RequiredExecutionEnvironment: J2SE-1.5
改成最新的eclipse repository后,所有测试都编译通过了