SecurityHeader的Glassfish Metro ClassCastException

时间:2017-02-13 13:44:53

标签: java wsdl glassfish

我正在使用wsimport生成我的类。在运行时,我得到了这个例外:

Exception in thread "main" javax.xml.ws.WebServiceException: java.lang.ClassCastException: com.sun.xml.ws.message.jaxb.JAXBHeader cannot be cast to com.sun.xml.ws.security.opt.impl.outgoing.SecurityHeader
at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processRequest(SecurityClientTube.java:250)
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
    at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
    at com.sun.xml.ws.client.Stub.process(Stub.java:464)
    at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
    at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)
    at com.sun.proxy.$Proxy57.listAddressByPostcode(Unknown Source)
    at uk.co.example.eaddress.EAddrServiceTest.directAddressTest(EAddrServiceTest.java:95)
    at uk.co.example.eaddress.EAddrServiceTest.main(EAddrServiceTest.java:41)
Caused by: java.lang.ClassCastException: com.sun.xml.ws.message.jaxb.JAXBHeader cannot be cast to com.sun.xml.ws.security.opt.impl.outgoing.SecurityHeader
    at com.sun.xml.ws.security.opt.impl.JAXBFilterProcessingContext.setJAXWSMessage(JAXBFilterProcessingContext.java:166)
    at com.sun.xml.wss.jaxws.impl.SecurityTubeBase.secureOutboundMessage(SecurityTubeBase.java:383)
    at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processClientRequestPacket(SecurityClientTube.java:323)
    at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processRequest(SecurityClientTube.java:247)
    ... 12 more

我的pom.xml包含这些依赖项。

    <dependency>
        <groupId>org.glassfish.metro</groupId>
        <artifactId>webservices-rt</artifactId>
        <version>2.3</version>

    </dependency>
    <dependency>
        <groupId>org.apache.wss4j</groupId>
        <artifactId>wss4j-ws-security-common</artifactId>
        <version>2.1.7</version>
    </dependency>

我有另一个wsdl生成的服务具有完全相同的依赖关系,当我检查Eclipse中的pom依赖关系层次结构时,它们是相同的。这个其他wsdl生成的服务工作。我看不出它们之间的区别。

我意识到这个JAXBHeader可能不应该在类路径上,但是我找不到它所在的jar。或者如果类加载器加载满足相同接口的类的顺序,我看不出如何排除JAXBHeader类。谷歌搜索的其他问题来自手动构建这些安全头类的人,我的是使用wsimport生成的。

想法?

0 个答案:

没有答案