【问题标题】:NoSuchMethodError - MtomStreamWriter.getAttachmentMarshaller()NoSuchMethodError - MtomStreamWriter.getAttachmentMarshaller()
【发布时间】:2021-07-19 08:24:14
【问题描述】:

我正在使用wsdl 连接,当我收到响应时,我收到如下错误。

不过,我已经有这样的class了。

以下是我使用的所有dependency

<dependencies>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-tools</artifactId>
        <version>3.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>3.0.0</version>
    </dependency>
    <dependency>
        <groupId>javax.jws</groupId>
        <artifactId>javax.jws-api</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>rt</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.stream.buffer</groupId>
        <artifactId>streambuffer</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>org.jvnet.staxex</groupId>
        <artifactId>stax-ex</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.soap</groupId>
        <artifactId>javax.xml.soap-api</artifactId>
        <version>1.4.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.messaging.saaj</groupId>
        <artifactId>saaj-impl</artifactId>
        <version>1.5.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.gmbal</groupId>
        <artifactId>gmbal-api-only</artifactId>
        <version>4.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.jvnet.staxex</groupId>
        <artifactId>stax-ex</artifactId>
        <version>2.0.0</version>
    </dependency>

</dependencies>

我不明白为什么会出现这样的错误。在此先感谢您的回答。

【问题讨论】:

标签: jakarta-ee wsdl jax-ws java-11 mtom


【解决方案1】:

我在使用Jakarta 和启用MTOM 后遇到了同样的问题。
我现在使用Java 17

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: 'jakarta.xml.bind.attachment.AttachmentMarshaller org.jvnet.staxex.util.MtomStreamWriter.getAttachmentMarshaller()'

stax-ex-1.8.jar 中,此方法的返回类型为javax.xml.bind.attachment.AttachmentMarshaller,而不是错误消息中显示的预期jakarta.xml.bind.attachment.AttachmentMarshaller

这是我的pom.xml 中存在问题的依赖项:

...
<dependency> <!-- Not good -->
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency> <!-- Not good -->
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.1</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>jakarta.xml.ws</groupId>
    <artifactId>jakarta.xml.ws-api</artifactId>
    <version>3.0.1</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>3.0.2</version>
</dependency>
...

以下是新的良好依赖项:

...
<!-- JAXB API v3.0.1 -->
<dependency>
    <groupId>jakarta.xml.bind</groupId>
    <artifactId>jakarta.xml.bind-api</artifactId>
    <version>3.0.1</version>
</dependency>
<!-- JAXB v3.0.2 reference implementation -->
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>3.0.2</version>
    <scope>runtime</scope>
</dependency>

<dependency>
    <groupId>jakarta.xml.ws</groupId>
    <artifactId>jakarta.xml.ws-api</artifactId>
    <version>3.0.1</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>3.0.2</version>
</dependency>
...

stax-ex-1.8.jar 现在替换为stax-ex-2.0.1.jar
然后,我的客户端网络服务Jakarta JAX-WS 在启用MTOM 的情况下工作正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-20
    • 2018-04-08
    • 2019-05-07
    • 2015-12-23
    • 2015-09-11
    • 2017-08-27
    • 2020-11-08
    • 1970-01-01
    相关资源
    最近更新 更多