Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1568

Versions 2.21 and higher doesn't work with junit-platform for Java 9 module

    XMLWordPrintableJSON

Details

    Description

      I have a simple JPMS module. When I use the maven-surefire-plugin 2.20.1 everything is ok - my tests are executed:

                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <version>2.20.1</version>
                          <dependencies>
                              <dependency>
                                  <groupId>org.junit.platform</groupId>
                                  <artifactId>junit-platform-surefire-provider</artifactId>
                                  <version>1.3.0</version>
                              </dependency>
                          </dependencies>
                  </plugin>

      However, when I want to use newer versions of surefire (2.21.0 or 2.22.0) I get the following:

          Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
          The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
          Command was /bin/sh -c cd "/home/project" && /opt/jdk-9/bin/java '@/home/project/target/surefire/surefireargs4438382394951202560' '/home/project/target/surefire' 2018-09-13T13-42-05_435-jvmRun1 surefire4870497011802680670tmp surefire_015850140770716473411tmp
          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 /bin/sh -c cd "/home/project" && /opt/jdk-9/bin/java '@/home/project/target/surefire/surefireargs4438382394951202560' '/home/project/target/surefire' 2018-09-13T13-42-05_435-jvmRun1 surefire4870497011802680670tmp surefire_015850140770716473411tmp
          Error occurred in starting fork, check output in log
          Process Exit Code: 1
          at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:671)
          at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
          at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:278)
          at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:244)
          at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1194)
          at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1022)
          at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:868)
          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 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:564)
          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)
          -> [Help 1]

      And in surefire-reports I see the following:

          # Created at 2018-09-13T13:42:07.587
          Error: Could not find or load main class Projects..home.project.m2.repository.org.eclipse.persistence.javax.persistence.2.2.0.javax.persistence-2.2.0.jar:.home.project..m2.repository.org.eclipse.persistence.org.eclipse.persistence.core.2.7.0.org.eclipse.persistence.core-2.7.0.jar:.home.project..m2.repository.org.slf4j.slf4j-api.1.7.25.slf4j-api-1.7.25.jar ...
          
          # Created at 2018-09-13T13:42:07.588
          Caused by: java.lang.ClassNotFoundException: /home/project//m2/repository/org/eclipse/persistence/javax/persistence/2/2/0/javax/persistence-2/2/0/jar:/home/project//m2/repository/org/eclipse/persistence/org/eclipse/persistence/core/2/7/0/org/eclipse/persistence/core-2/7/0/jar:/home/project//m2/repository/org/slf4j/slf4j-api/1/7/25/slf4j-api-1/7/25/jar ...

      I tried to use only Junit jupiter as explained here https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html but result is the same. Maybe the problem is that surefire builds wrong path? See

      :/home/project//m2/repository/org/slf4j/slf4j-api/1/7/25/slf4j-api-1/7/25/jar
      

      As you see there are two slashes before m2. The question about this problem was asked also on SO https://stackoverflow.com/questions/52312151/maven-surefire-plugin-with-junit-platform-surefire-provider-for-java-9-module

      Attachments

        1. 2018-09-15T18-54-48_266.dumpstream
          0.4 kB
          Pavel_K
        2. debug1.txt
          87 kB
          Pavel_K
        3. debug2.txt
          87 kB
          Pavel_K
        4. mavenproject19_target_and_debug.zip
          19 kB
          Pavel_K
        5. mavenproject19.zip
          4 kB
          Pavel_K

        Activity

          People

            tibordigana Tibor Digana
            Pavel_K Pavel_K
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: