Recently coming to a new project, I\'m trying to compile our source code. Everything worked fine yesterday, but today is another story.
Every time I\'m running
I have another workaround. Set the environment variable _JAVA_OPTIONS. I've used this for our TeamCity build agents and now our builds run fine.
_JAVA_OPTIONS=-Djdk.net.URLClassPath.disableClassPathURLCheck=true
Set useSystemClassloader to false:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
If you're not inheriting from a parent which has version defined for you (such as the Spring Boot starter) you'll need to define that as well.
I found this workaround and fixed my tests: configure the maven-surefire-plugin
not to use the system classloader.
Basically is an incompatibility between JDK version and maven-surefire plugin version, in my case, JDK 11.0.5 doesn't work with surefire 3.0.0-M4, I had to switch to 3.0.0-M3 and it worked. setting forkCount to 0 doesn't fix the issue because it breaks the Jacoco report.
When using GitLab CI/CD with 3.6.0-jdk-8
image only the property below helped (without modifying pom.xml
).
-Dsurefire.useSystemClassLoader=false
The suggestion above to set the property "-Djdk.net.URLClassPath.disableClassPathURLCheck=true" did NOT work for me, but setting the following does work OK:
-DforkCount=0