How to work java 9 modules with Maven Surefire Plugin?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to work java 9 modules with Maven Surefire Plugin?

Alex Sviridov

Hi all,

I want to test my JPMS module using maven surefire plugin (2.22) with junit5. For this I added the following to my pom:

...
           <dependency>
               <groupId>org.junit.jupiter</groupId>
               <artifactId>junit-jupiter-engine</artifactId>
               <version>5.3.0</version>
               <scope>test</scope>
            </dependency>
...
           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
                <configuration>
                    <excludes>
                        <exclude>**/IT*.java</exclude>
                    </excludes>
                </configuration>
            </plugin>

However, I have this error:

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 orSystem.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
ProcessExitCode:1
org.apache.maven.surefire.booter.SurefireBooterForkException:The forked VM terminated without properly saying goodbye. VM crash orSystem.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
ProcessExitCode: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(NativeMethod)
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)->[Help1]
And in surefire-reports I see the following:
# Created at 2018-09-13T13:42:07.587Error:Couldnot find or load main classProjects..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.588Causedby: 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 ... Could anyone explain what I do wrong? It seems to me that I don't use module-path while testing but how to use it I didn't find. Maybe any links to examples.
Please, help.

--
Best regards, Alex Sviridov