Issue
I'm upgrading from Java 8 to Java 11.
I'm using javax.ws packages so I had to include dependencies removed in Java 11.
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.3-b01</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.3-b01</version>
</dependency>
My Spring Boot 2.2.2 application works perfect running like mvn spring-boot:run
.
When running with java -jar app.jar gives a ClassNotFoundException
while searching for com.sun.xml.ws.spi.ProviderImpl
I checked the rt-version.jar is in the final fat jar.
And checked the class is in the jar.
Does spring boot remove classes from ClassLoader when running in java -jar
mode?
Solution
The real problem was a change of behavior as of Java9.
ForkJoinPools now don't have main thread classloader, they have system classloader instead.
But Java 11 allows more params in ForkJoinPool constructor so we can create our own pools with our desired classloader.
The solution is posted in another answer. https://stackoverflow.com/a/59444016/878015
Answered By - David Canós
Answer Checked By - Senaida (JavaFixing Volunteer)