I have a simple spring project based on the official guide to consume a web service. This sample seems to be targeting JDK 8 but I want to use the latest LTS, JDK 11.
I have adapted the pom.xml
file and added some dependencies which seem to have been removed from the JDK, namely:
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
However, I can't seem to start the application, I always get this error:
➜ spring-test git:(master) mvn spring-boot:run
[INFO] Scanning for projects...
...
org.springframework.ws.soap.client.SoapFaultClientException: Implementation of JAXB-API has not been found on module path or classpath.
at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault (SoapFaultMessageResolver.java:38)
at org.springframework.ws.client.core.WebServiceTemplate.handleFault (WebServiceTemplate.java:830)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive (WebServiceTemplate.java:624)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive (WebServiceTemplate.java:555)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive (WebServiceTemplate.java:390)
at com.example.demo.CountryClient.getCountry (CountryClient.java:21)
at com.example.demo.DemoApplication.lambda$lookup$0 (DemoApplication.java:24)
at org.springframework.boot.SpringApplication.callRunner (SpringApplication.java:781)
at org.springframework.boot.SpringApplication.callRunners (SpringApplication.java:765)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:319)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1215)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1204)
at com.example.demo.DemoApplication.main (DemoApplication.java:13)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:543)
at java.lang.Thread.run (Thread.java:834)
Although there are at least two questions (this and this) related to this topic, I've tried all combinations of versions that I could find in those posts and I still have the same error.
The specific JDK+maven version I'm using is:
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T16:06:16+01:00)
Maven home: /usr/local/Cellar/maven/3.6.2/libexec
Java version: 11.0.4, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.4.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
And the code for my test is here.
Take a look at this answer and check if it may help you. We have a couple of projects using Java 11 with Spring WS and everything is working just fine. Also make sure that your pom.xml
is targeting Java 11:
<properties>
<java.version>11</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
</properties>
Regarding the missing classes, we had to add the following dependency, and nothing else:
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
we must add the following dependence
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>
insted :
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
it is a problem for all version of the jdk 11 even on amazone correto
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With