JAXB解析XML遇到的异常:意外的元素,我擦嘞,求助求助,搞不定啊!

Credo-Zhao 发布于 2012/12/04 16:33
阅读 10K+
收藏 0

用的JAXB解析XML文件,

<?xml version = '1.0'?>
<RtavMessage xmlns="rtav.fidelio.2.0">
这个是XML的开头,第二行的 xmlns="rtav.fidelio.2.0"在用JAXB解析的过程中报错,报unexpected element ,异常如下:求助大侠,怎么解决......

15:22:53,104 INFO  [cn.shijinet.kunlun.integration.rest.OxiV1RsService] (http-localhost/127.0.0.1:8080-1) PMS酒店房态上传CRS(房量)
15:22:53,468 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) javax.xml.bind.UnmarshalException: 意外的元素 (uri:"rtav.fidelio.2.0", local:"RtavMessage")。所需元素为(none)


15:22:53,469 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:662)


15:22:53,469 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:258)


15:22:53,470 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:253)


15:22:53,470 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:120)


15:22:53,470 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1063)


15:22:53,470 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:498)


15:22:53,470 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:480)


15:22:53,471 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:150)


15:22:53,471 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)


15:22:53,471 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)


15:22:53,471 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)


15:22:53,472 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)


15:22:53,472 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)


15:22:53,472 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)


15:22:53,472 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)


15:22:53,472 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)


15:22:53,473 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)


15:22:53,473 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)


15:22:53,473 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:218)


15:22:53,473 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:190)


15:22:53,474 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:136)


15:22:53,474 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:183)


15:22:53,474 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at cn.shijinet.kunlun.integration.rest.OxiV1RsService.messageUploadToJMS(OxiV1RsService.java:43)


15:22:53,474 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at cn.shijinet.kunlun.integration.rest.OxiV1RsService$Proxy$_$$_WeldClientProxy.messageUploadToJMS(OxiV1RsService$Proxy$_$$_WeldClientProxy.java)


15:22:53,474 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


15:22:53,475 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)


15:22:53,475 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)


15:22:53,475 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at java.lang.reflect.Method.invoke(Method.java:601)


15:22:53,475 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)


15:22:53,475 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)


15:22:53,476 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)


15:22:53,476 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)


15:22:53,476 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525)


15:22:53,476 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502)


15:22:53,477 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)


15:22:53,477 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)


15:22:53,477 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)


15:22:53,477 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)


15:22:53,477 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)


15:22:53,478 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)


15:22:53,478 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)


15:22:53,478 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)


15:22:53,478 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)


15:22:53,478 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)


15:22:53,479 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)


15:22:53,479 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)


15:22:53,479 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)


15:22:53,479 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)


15:22:53,479 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)


15:22:53,479 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)


15:22:53,480 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)


15:22:53,480 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)


15:22:53,480 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)


15:22:53,480 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:165)


15:22:53,480 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)


15:22:53,481 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)


15:22:53,481 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)


15:22:53,481 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372)


15:22:53,481 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)


15:22:53,481 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)


15:22:53,481 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)


15:22:53,482 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at java.lang.Thread.run(Thread.java:722)



加载中
0
javacc
javacc

<RtavMessage xmlns="rtav.fidelio.2.0">你的错误信息,是说,xmlns后面应该是一个url地址的,可是发现了这个家伙rtav.fidelio.2.0 ,解析不了了,你把它删掉试试。或者换成一个url地址,看下

Aelns
Aelns
回复 @Zhao-Qian : 遇到一个类似的问题, 你的回复提醒了我, 谢谢~
Credo-Zhao
Credo-Zhao
实体bean那里少了 @XmlRootElement(name="XXX") 了.加上这个注解就可以了.多写朋友帮忙看...谢谢你.
0
返回顶部
顶部