I have a simple project which uses maven, spring-boot, and connects to a postresql-Database. When I run mvn clean install, everything runs fine, even the tests. (I am compiling it with java 10) Then I add a module-info.java to turn it into a java9 module. Now, if I build it and I don't -DskipTests, I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project birdtree-model-dao: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Programming practice\Mentoring Donna Informatica\birdtree_project\birdtree_java_workspace\birdtree-model-dao\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk-10.0.1\bin\java" @C:\Users\Manuela\AppData\Local\Temp\surefire16709347194940961814\surefireargs14150574352838310253 C:\Users\Manuela\AppData\Local\Temp\surefire16709347194940961814 2019-05-01T01-23-43_537-jvmRun1 surefire9560741769530673276tmp surefire_08315816585779964257tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk-10.0.1\bin\java" @C:\Users\Manuela\AppData\Local\Temp\surefire16709347194940961814\surefireargs14150574352838310253 C:\Users\Manuela\AppData\Local\Temp\surefire16709347194940961814 2019-05-01T01-23-43_537-jvmRun1 surefire9560741769530673276tmp surefire_08315816585779964257tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
...
And the surefire-reports file contains:
# Created at 2019-05-01T00:58:57.663
Error: Could not find or load main class practice\Mentoring
# Created at 2019-05-01T00:58:57.663
Caused by: java.lang.ClassNotFoundException: practice\Mentoring
(Sounds kind of like the issue is the space in the file path, right? But if it is, where do I correct that?)
So, I assume it must be the fault of the module-info, since that's the only thing that changed. I've struggled with what to put in it. The one Eclipse generated automatically seemed wrong, e.g. cause it includes test dependencies, which gave me other errors. So I tried around and it currently looks like this:
module birdtreeModelDao {
exports mjl.familytree.birdtree;
//requires junit; //eclipse adds this. But I think test dependencies don't belong here, right?
requires spring.boot;
requires spring.boot.autoconfigure; //included this externally by creating new library
//requires spring.boot.test; //eclipse adds this. But it just gives me other errors. And again, it's a test dependency, so surely it shouldn't be here.
requires spring.context;
}
Here's my pom:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>mjl.familytree</groupId>
<artifactId>birdtree-model-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>birdtree-model-dao</name>
<description>Manuela's family tree program</description>
<repositories>
<repository>
<id>repository.spring.release</id>
<name>Spring GA Repository</name>
<url>http://repo.spring.io/release</url>
</repository>
</repositories>
<properties>
<maven.compiler.source>1.10</maven.compiler.source><!-- 1.12 -->
<maven.compiler.target>1.10</maven.compiler.target><!-- 1.12 -->
<maven.compiler.release>10</maven.compiler.release>
<java.version>10</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-data-rest</artifactId> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-web</artifactId> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-web-services</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<!-- <version>4.12</version> -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- https://stackoverflow.com/questions/50661648/spring-boot-fails-to-run-maven-surefire-plugin-classnotfoundexception-org-apache/50661649#50661649 -->
<!-- Used this to try to prevent "The forked VM terminated without properly saying goodbye" when running with tests and with module-info.java -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
</project>
Any idea what's causing the error?