JDK 11:java.lang.NoClassDefFoundError:javax / xml / ws / handler / soap / SOAPHandler

Pat*_*tty 5 java

我们正在从jdk 8迁移到openjdk11。我们的一些使用soap调用第三方api的项目均因错误而失败:

java.lang.NoClassDefFoundError: javax/xml/ws/handler/soap/SOAPHandler
Run Code Online (Sandbox Code Playgroud)

经过一些研究,我尝试通过添加依赖项:

[ 参考:

]

 <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
    </dependency>
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</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.1</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.soap</groupId>
        <artifactId>javax.xml.soap-api</artifactId>
        <version>1.3.5</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

不工作。我可以对替代方案有所了解吗?

Joh*_*Eye 17

javaxAPI的被转移到Jakarta,所以在2020年的适当的依赖如下:

<dependency>
    <groupId>jakarta.xml.ws</groupId>
    <artifactId>jakarta.xml.ws-api</artifactId>
    <version>2.3.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

这是一篇总结发生的事情的文章: Java Magazine - Transition from Java EE to Jakarta EE

这是一个非常有用的表格,其中包含旧工件和新工件之间的映射


Dav*_*rad 5

包括jaxws-api在您的依赖项中:

<dependency>
    <groupId>javax.xml.ws</groupId>
    <artifactId>jaxws-api</artifactId>
    <version>2.3.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

  • 如果您使用 Microsoft EWS 库并且遇到相同的异常,则此依赖项有助于解决问题。 (2认同)