Java 11: import javax.xml.ws.WebFault: "Cannot resolve symbol ws"
Asked Answered
V

2

9

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).

Vedis answered 2/8, 2019 at 0:19 Comment(0)
V
14

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>
Vedis answered 2/8, 2019 at 0:35 Comment(0)
D
1

In my case the only dependency necessary to add was:

compile "com.sun.xml.ws:jaxws-ri:2.3.3"

For some reason the version 2.3.0 had some unknow dependies being referenced.

Druse answered 12/9, 2020 at 3:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.