javax.xml.bind.UnmarshalException 在 CXF 中
javax.xml.bind.UnmarshalException in 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.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.parse(RuntimeBuiltinLeafInfoImpl.java:819)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.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.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.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.run(UDPDestination.java:114)
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl.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.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.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>
web.xml
<?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>
更多详情:
应用程序服务器:Tomcat 7
JDK/JRE 版本:1.7.0_75
问题:
我是不是配置错误导致了这个异常?还是跟CXF版本有关?
有什么方法可以解决这个烦人的异常。
仅供参考,
它与 apache-cxf-2.7.17 一起工作正常
并且此异常不会停止任何功能。
谢谢,
您似乎开启了 WS-Discovery。这是通过在类路径中放置 cxf-services-ws-discovery-service
和 cxf-services-ws-discovery-api
来完成的。从您的类路径中删除这些(例如从 Maven pom.xml),您应该不会再看到错误消息。
如果上述解决方案不起作用,我通过更改项目方面配置修复了同样的错误。
转到您的项目属性-> 项目方面关闭 CXF 2.x Web 服务,并检查动态 Web 模块是否已打开。如果您在 Jboss 或 Wildfly 8.x 上部署,它们将使用您需要的必要 cfx 库,并在您的 pom.xml
上声明
我在 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.parse(RuntimeBuiltinLeafInfoImpl.java:819)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.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.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.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.run(UDPDestination.java:114)
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl.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.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.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>
web.xml
<?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>
更多详情:
应用程序服务器:Tomcat 7
JDK/JRE 版本:1.7.0_75
问题:
我是不是配置错误导致了这个异常?还是跟CXF版本有关?
有什么方法可以解决这个烦人的异常。
仅供参考,
它与 apache-cxf-2.7.17 一起工作正常
并且此异常不会停止任何功能。
谢谢,
您似乎开启了 WS-Discovery。这是通过在类路径中放置 cxf-services-ws-discovery-service
和 cxf-services-ws-discovery-api
来完成的。从您的类路径中删除这些(例如从 Maven pom.xml),您应该不会再看到错误消息。
如果上述解决方案不起作用,我通过更改项目方面配置修复了同样的错误。
转到您的项目属性-> 项目方面关闭 CXF 2.x Web 服务,并检查动态 Web 模块是否已打开。如果您在 Jboss 或 Wildfly 8.x 上部署,它们将使用您需要的必要 cfx 库,并在您的 pom.xml
上声明