cxf 报错:prefix wsdp is not bound to a namespace

笔者最近在使用cxf框架过程中,当服务端发布service时,出现了一个BUG
打印栈轨如下:

//wsdp前缀不能绑定到名称空间
javax.xml.bind.UnmarshalException: prefix wsdp is not bound to a namespace
 - with linked exception:          
[java.lang.IllegalArgumentException: prefix wsdp is not bound to a namespace]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:740)

//引发异常的源头在:
Caused by: java.lang.IllegalArgumentException: prefix wsdp is not
> bound to a namespace
    at com.sun.xml.bind.DatatypeConverterImpl._parseQName(DatatypeConverterImpl.java:369)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$23.parse(RuntimeBuiltinLeafInfoImpl.java:817)
    ... 39 more

网上提供了的解决办法最有用的就是:删除多余的包

  1. cxf-services-ws-discovery-api-3.1.4.jar
  2. services-ws-discovery-service-3.1.4.jar
  3. services-wsn-api-3.1.4.jar
  4. services-wsn-core-3.1.4.jar
    5.manifest.jar
    从lib中的which_jar文件中(其实就是个文本)有这样的话:

This directory includes the CXF jar, the CXF manifest jar, the
required dependencies, and many optional dependencies. The “modules”
directory contains the cxf.jar split up into smaller pieces if you
—-这是说:这个cxf包可以按需取用部分
………………………..
然后:
For the WS-Discovery Service
- cxf-ws-discovery-api.jar
- cxf-ws-discovery-service.jar

这说明上面提到要删除的包其实是为了启用WS-Discovery服务的.
传统的服务调用模式:客户端在设计时就知道目标服务的地址,并根据这个地址创建客户端结点对服务进行调用;
而启用本项服务,可以在不知道目标服务地址的情况下,动态探测可用的服务并调用,就像动态获取WiFi服务一般.因此看起来myEclipse工具的控制台每隔几分钟就会刷一次,然后继续报一堆错!

而which_jar 也写到了
For the WS-Notification Service:
- cxf-services-wsn-api.jar
- cxf-services-wsn-core.jar
- activemq*.jar
- hawtbuf.jar
- geronimo-j2ee-management_1.1_spec.jar
就是说,要是启用WS-Notification服务,就必须加这些包.

WS-Notification(WSN)是一系列规范,它制定了在 Web 服务环境中创建事件驱动系统的标准流程,对希望接收有关特定主题的需求方发送特定的需求信号.

再看:

The ‘manifest jar’ is a jar containing only a MANIFEST.MF with a classpath that calls in all the other jar.
即:manifest jar’只有MANIFEST.MF,能够调用所有其他jar包.有人反映删除了前面的四个包还是会报异常,那是因为这里写死的路径还在,程序仍然会试图调用这些服务

MANIFEST.MF的东西长这样的:

此处省略废话……………………..

Class-Path: cxf-3.0.12.jar endorsed/jaxb-api-2.2.11.jar endorsed/geron
imo-jaxws_2.2_spec-1.2.jar jaxb-impl-2.2.11.jar jaxb-core-2.2.11.jar
jaxb-impl-2.1.14.jar jaxb-core-2.1.14.jar jaxb-xjc-2.2.11.jar jaxb-xj
c-2.1.14.jar cxf-tools-common-3.0.12.jar velocity-1.7.jar commons-collections-3.2.2.jar
………………..此处省略N字

综上所述:要解决这个问题,删了这些用不到的包.否则程序默认是要开启的.这些类路径都是在ManiFest.里,如果还解决不了,把这个也删了.

猜你喜欢

转载自blog.csdn.net/qq_30118563/article/details/57176534
今日推荐