Apache CXF中的javax.xml.bind.UnmarshalException

Apache CXF中的javax.xml.bind.UnmarshalException,apache,web-services,rest,soap,cxf,Apache,Web Services,Rest,Soap,Cxf,我在apache-cxf-3.1.2中遇到以下异常,并尝试了很多方法来解决它,但没有得到任何积极的帮助,因此计划并升级到最新版本apache-cxf-3.1.4,但在apache-cxf-3.1.4中厄运问题仍然存在 DefaultValidationEventHandler: [ERROR]: prefix wsdp is not bound to a namespace Location: node: [wsd:Types: null] javax.xml.bind.Unmarshal

我在apache-cxf-3.1.2中遇到以下异常,并尝试了很多方法来解决它,但没有得到任何积极的帮助,因此计划并升级到最新版本apache-cxf-3.1.4,但在apache-cxf-3.1.4中厄运问题仍然存在

 DefaultValidationEventHandler: [ERROR]: prefix wsdp is not bound to a namespace 
Location:  node: [wsd:Types: null]
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)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:770)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:766)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$23.parse(RuntimeBuiltinLeafInfoImpl.java:819)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$23.parse(RuntimeBuiltinLeafInfoImpl.java:814)
at com.sun.xml.bind.v2.runtime.reflect.ListTransducedAccessorImpl.processValue(ListTransducedAccessorImpl.java:140)
at com.sun.xml.bind.v2.runtime.reflect.ListTransducedAccessorImpl.parse(ListTransducedAccessorImpl.java:155)
at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:65)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:589)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.text(InterningXmlVisitor.java:93)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.processText(SAXConnector.java:213)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:176)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:255)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:281)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:369)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:352)
at org.apache.cxf.common.jaxb.JAXBUtils.unmarshall(JAXBUtils.java:187)
at org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl$WSDiscoveryProvider.invoke(WSDiscoveryServiceImpl.java:502)
at org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl$WSDiscoveryProvider.invoke(WSDiscoveryServiceImpl.java:420)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.performInvocation(JAXWSMethodInvoker.java:66)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:85)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:74)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$2.run(ServiceInvokerInterceptor.java:126)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.udp.UDPDestination$MCastListener$2.run(UDPDestination.java:114)
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)
at java.lang.Thread.run(Unknown Source)
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)
... 41 more
请在下面找到cxf.xml和web.xml

cxf.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://cxf.apache.org/jaxrs
    http://cxf.apache.org/schemas/jaxrs.xsd">
    <!-- <import resource="classpath:META-INF/cxf/cxf.xml" /> -->
    <jaxrs:server id="base" address="/Restful">

    <jaxrs:serviceBeans>
    <ref bean="Service" />
    </jaxrs:serviceBeans>
    </jaxrs:server>
    <bean id="Service" class="com.xxx.yyy.services.ServiceImpl" />
    </beans>
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>V1.6</display-name>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/cxf.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
    <listener-class>com.xxx.yyy.services.InitListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>CXFServlet</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    </web-app>

web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://cxf.apache.org/jaxrs
    http://cxf.apache.org/schemas/jaxrs.xsd">
    <!-- <import resource="classpath:META-INF/cxf/cxf.xml" /> -->
    <jaxrs:server id="base" address="/Restful">

    <jaxrs:serviceBeans>
    <ref bean="Service" />
    </jaxrs:serviceBeans>
    </jaxrs:server>
    <bean id="Service" class="com.xxx.yyy.services.ServiceImpl" />
    </beans>
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>V1.6</display-name>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/cxf.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
    <listener-class>com.xxx.yyy.services.InitListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>CXFServlet</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    </web-app>

V1.6
上下文配置位置
WEB-INF/cxf.xml
org.springframework.web.context.ContextLoaderListener
com.xxx.yyy.services.InitListener
CXF服务器
org.apache.cxf.transport.servlet.CXFServlet
1.
CXF服务器
/*
更多详细信息:

应用服务器:Tomcat 7

JDK/JRE版本:1.7.0_75

问题:

  • 我做过任何导致此异常的错误配置吗?还是与CXF版本相关

  • 有没有办法解决这个恼人的异常

  • 供参考,

    • 它可以与apache-cxf-2.7.17配合使用

    • 这个例外不停止任何功能


    谢谢,

    看起来你已经开机了。这是通过将
    cxf服务ws-discovery服务
    cxf服务ws-discovery api
    放在类路径中完成的。从类路径(例如从maven pom.xml)中删除这些选项,您将不会再看到错误消息。

    看起来您已经打开了。这是通过将
    cxf服务ws-discovery服务
    cxf服务ws-discovery api
    放在类路径中完成的。从类路径(例如从maven pom.xml)中删除这些,您将不会再看到错误消息。

    如果上述解决方案不起作用,我通过更改项目方面配置修复了相同的错误


    转到您的项目属性->项目方面关闭CXF2.xWeb服务,并检查DynamicWebModule是否已打开。如果您在Jboss或Wildfly 8.x上部署,他们将使用您需要的必要cfx库,并在pom.xml上声明。如果上述解决方案不起作用,我通过更改项目方面配置修复了相同的错误


    转到您的项目属性->项目方面关闭CXF2.xWeb服务,并检查DynamicWebModule是否已打开。如果您在Jboss或Wildfly 8.x上部署,他们将使用您需要的、在pom.xml上声明的必要的cfx库

    这里我没有使用maven,我在上面给出了我的cxf.xml和web.xml,您知道如何删除cxf服务ws-discovery api吗?据我所知,我并不专门使用它。我是否需要从CXF中移除任何罐子,以解决此问题?完全正确。尝试删除它们,看看会发生什么:)从CXF中删除这些jar似乎可以解决问题,CXF-services-ws-discovery-api-3.1.4.jar CXF-services-ws-discovery-service-3.1.4.jar CXF-services-wsn-api-3.1.4.jar但是您知道这是否会影响到CXF的任何功能吗?不,它不会影响您的场景,因为RESTful服务不需要WS-Discovery和WS-Notifications。这里我没有使用maven,我在上面给出了我的cxf.xml和web.xml,您知道如何删除cxf服务WS-Discovery api吗?据我所知,我并不专门使用它。我是否需要从CXF中移除任何罐子,以解决此问题?完全正确。尝试删除它们,看看会发生什么:)从CXF中删除这些jar似乎可以解决问题,CXF-services-ws-discovery-api-3.1.4.jar CXF-services-ws-discovery-service-3.1.4.jar CXF-services-wsn-api-3.1.4.jar但是您知道这是否会影响到CXF的任何功能吗?不,它不会影响您的场景,因为RESTful服务不需要WS-Discovery和WS-Notification。