Issue
I'm attempting to upgrade a service to Java 11.
We currently use wsdl2java (Apache CXF) to generate source code based on WSDLs. I'm doing this all via Maven. The source files generate properly based on the wsdl.
Unfortunately, some of the source files generated include the following imports:
import javax.xml.ws.WebFault;
import javax.jws.WebService;
I'm missing the packages javax.xml.ws and javax.jws.
In my research, I have discovered that Jaxb was deprecated out of the main JDK, thus I need to add new dependencies into my pom. I've tried various combinations, but they all come down to something like:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
Unfortunately, no matter what I do, my IDE just can't seem to find javax.xml.ws and javax.jws.
Does anyone know what dependency I may need to include so that I get these packages?
And though it's not specifically at the core of the problem, here's my wsdl2java stuff:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.3.2</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf/</sourceRoot>
<wsdlRoot>src/main/webapp/resources/wsdl/fedex</wsdlRoot>
<includes>
<include>**/*.wsdl</include>
</includes>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
(Yes, I'm generating a fedex client).
Solution
As so often happens, I found the answer to this right after posting this question. I added an additional dependency, and that seems to have fixed it. Added dependency was:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.0</version>
<type>pom</type>
</dependency>
All my Jaxb dependencies together look like...
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</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>jaxws-ri</artifactId>
<version>2.3.0</version>
<type>pom</type>
</dependency>
Answered By - Joey
Answer Checked By - David Goodson (JavaFixing Volunteer)