Unmarshaller异常javax.xml.bind.UnmarshalException: unexpected element处理方法
来源:互联网 发布:js 定义utf16 编辑:程序博客网 时间:2024/06/05 17:56
在marshaller/Unmarshaller开发过程中可能会遇到javax.xml.bind.UnmarshalException: unexpected element异常,比如
unexpected element (uri:"", local:"Group"). Expected elements are <{}group>
Meet an exception when unmarshalling from xml
JAXBContext jc = JAXBContext.newInstance(Group.class);Unmarshaller unmarshaller = jc.createUnmarshaller();Group group = (User)unmarshaller.unmarshal(new File("group.xml"));
通常的解决方法是:
- Change the root element on your XML to be "group"
- Add the annotation @XmlRootElement(name="Group") to the Group classs.
但有时这样做了,还是不能解决问题。原因在于ObjectFactory类。
在开发的过程中我们可能是根据XSD文件(XML文件的格式文件),通过JDK的/bin/xjc.exe生成java文件。有些时候我们会手工修改生成后的java文件;有些时候XSD文件会有冲突,我们会删除冲突的文件,分别生成java文件,这样就导致了xjc生成的ObjectFactory.java中没有包含全部的与XSD文件对应的方法。所以在删除冲突的XSD文件,分别生成java文件以后,要手动修改ObjectFactory.java,使之包含所有生成的java类的createXXX()方法。这样再编译打包,重现运行,就不会出现javax.xml.bind.UnmarshalException: unexpected element异常了。
- Unmarshaller异常javax.xml.bind.UnmarshalException: unexpected element处理方法
- javax.xml.bind.UnmarshalException: Unexpected element
- jaxb 将xml转化为bean时报异常javax.xml.bind.UnmarshalException: unexpected element
- Jaxb将xml转换为bean时异常javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"
- javax.xml.bind.UnmarshalException异常解决办法
- javax.xml.bind.UnmarshalException
- javax.xml.bind.UnmarshalException (uri:"", 解决办法
- 调用cxf生成的接口异常修复javax.xml.bind.UnmarshalException - with linked exception
- 调用webservice出现javax.xml.bind.UnmarshalException解决办法
- 关于cxf WebService中错误信息的解决 javax.xml.bind.UnmarshalException
- CXF javax.xml.ws.soap.SOAPFaultException: Unexpected wrapper element
- JAXB 的 UnmarshalException unexpected element 错误原因与解决方法
- javax.xml.bind.DatatypeConverter.printBase64Binary("abc".getBytes())报NullPointerException异常
- javax.xml.transform.TransformerFactoryConfigurationError异常处理
- com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:241) 多线程
- WebService异常Unexpected wrapper element ... found. Expected ...
- WebService异常Unexpected wrapper element ... found. Expected ...
- cxf Unexpected wrapper element异常解决
- 知名网站分享:PHP代替Perl,Redis置换MySQL,日处理过亿PV
- ArcGIS Runtime for IOS 几何对象与json的互相转换
- UVa156 Ananagrams
- PhoneGap Js 自动扩展输入框
- ZOJ 2836 容斥原理
- Unmarshaller异常javax.xml.bind.UnmarshalException: unexpected element处理方法
- The connection to adb is down, and a severe error has occured解决方案
- R中某些包安装出错的处理
- JsonUtils工具类
- strrchr()
- Codeforces 126D
- C++_ArcGIS10环境下读写中文属性值的问题
- CUDA的Threading:Block和Grid设定
- HadoopRPC机制分析系列之一: 动态代理