com.thoughtworks.xstream.converters.ConversionException

使用webService调用接口,返回的是xml格式,运用xstream解析的时候,出现了如下的错误:

 1 Exception in thread "Timer-1" com.thoughtworks.xstream.converters.ConversionException: For input string: "VS" : For input string: "VS"
 2 ---- Debugging information ----
 3 message             : For input string: "VS"
 4 cause-exception     : java.lang.NumberFormatException
 5 cause-message       : For input string: "VS"
 6 class               : java.lang.Integer
 7 required-type       : java.lang.Integer
 8 converter-type      : com.thoughtworks.xstream.converters.SingleValueConverterWrapper
 9 wrapped-converter   : com.thoughtworks.xstream.converters.basic.IntConverter
10 path                : /interface/items/roomstate
11 class[1]            : catic.hotel.server.webservice.Items
12 converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
13 class[2]            : catic.hotel.server.webservice.Interface
14 version             : null
15 -------------------------------
16     at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
17     at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
18     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
19     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:355)
20     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:306)
21     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
22     at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
23     at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
24     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
25     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
26     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:322)
27     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
28     at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
29     at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
30     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
31     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
32     at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
33     at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
34     at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1058)
35     at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1042)
36     at com.thoughtworks.xstream.XStream.fromXML(XStream.java:913)
37     at com.thoughtworks.xstream.XStream.fromXML(XStream.java:904)
38     at catic.library.util.XmlBeanConvertUtil.xml2Bean(XmlBeanConvertUtil.java:27)
39     at catic.library.util.XMLUtil.roomStatusXmlToList2(XMLUtil.java:86)
40     at catic.hotel.server.server.ReadDataByPMSOurDB$ReadPMSUptOurDB.run(ReadDataByPMSOurDB.java:104)
41     at java.util.TimerThread.mainLoop(Unknown Source)
42     at java.util.TimerThread.run(Unknown Source)
43 Caused by: java.lang.NumberFormatException: For input string: "VS"
44     at java.lang.NumberFormatException.forInputString(Unknown Source)
45     at java.lang.Long.parseLong(Unknown Source)
46     at java.lang.Long.valueOf(Unknown Source)
47     at java.lang.Long.decode(Unknown Source)
48     at com.thoughtworks.xstream.converters.basic.IntConverter.fromString(IntConverter.java:27)
49     at com.thoughtworks.xstream.converters.SingleValueConverterWrapper.fromString(SingleValueConverterWrapper.java:41)
50     at com.thoughtworks.xstream.converters.SingleValueConverterWrapper.unmarshal(SingleValueConverterWrapper.java:49)
51     at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
52     ... 26 more

由43行可以看出,是类型转换异常,因为返回的类型既有String,又有Integer,而我只用了Integer,忽略了String,所以报错。

刚开始还以为是使用xstream报的错,由于是第一次使用这个东东……不过,xstream这个东东真的很好用。

时间: 2024-10-12 13:37:28

com.thoughtworks.xstream.converters.ConversionException的相关文章

jmeter导入jmx文件报错:missing class com.thoughtworks.xstream.converters.ConversionException

有的时候我们会参考别人的jmx文件,但是在导入的时候会报错如下图: 实际上是告诉我们缺少jar包所引起的,下载对应jar包放到jmeter安装目录对应的lib/ext下就可以了,如下图: jmeter插件下载地址:https://jmeter-plugins.org/downloads/all/ jmeter-plugins-manager.jar是jmeter的一个插件管理工具包,下载完成之后,将下载的jmeter-plugins-manager-0.11.jar文件放置到jmeter目录下\

org.jvnet.hudson.reactor.ReactorException: com.google.common.util.concurrent.UncheckedExecutionException: com.thoughtworks.xstream.mapper.CannotResolveClassException: maven2-moduleset

org.jvnet.hudson.reactor.ReactorException: com.google.common.util.concurrent.UncheckedExecutionException: com.thoughtworks.xstream.mapper.CannotResolveClassException: maven2-moduleset at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:246) at h

建立Maven工程时出错,Failure to transfer com.thoughtworks.xstream:xstream:jar:1.3.1

Failure to transfer com.thoughtworks.xstream:xstream:jar:1.3.1 from http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. 解决办法: a.

eclipse中Maven项目pom.xml报错:com.thoughtworks.xstream.io.HierarchicalStreamDriver

解决方法: 把本地MAVEN库的该jar相关信息先删除,然后通过MAVEN重新构造一次即可 1.如下图我的本地Maven库关于 xstream包,删除红色框中的包! 2.然后新建一个maven项目,在pom中配置依赖: <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> <version>1.4.3</

用Xstream时候遇到的两个小异常

第一个 com.thoughtworks.xstream.converters.ConversionException: Cannot construct ClassXXX as it does not have a no-args constructor : Cannot construct yourpackage.yourclass as it does not have a no-args constructor 搜了一下才发现是版本的问题: 我用的是JDK7+XStream1.3.1 你

Linux下运行jmeter测试

主要介绍Jmeter脚本如何在Linux通过no GUI的方式运行 一.Linux下JDK的安装及环境变量的配置(可自行百度安装配置流程,window下安装的Jmeter和JDK要和Linux的保持一致) 二.Linux下Jmeter的安装及环境变量的配置(可自行百度安装配置流程,window下安装的Jmeter和JDK要和Linux的保持一致) 在执行jmeter脚本时,首先确认监控工具,jmeter以及相关文件有相应的权限,否则会报错,常见的报错: 1.文件没有权限 2.无法打开目录下文件

xstream读取xml

xStream可以Java和xml相互转换.下面主要说明xstream读取xml文件(和xstream将Java转化成xml差不多).本次学习用到的是xstream1.4.7 项目中使用到的xml文件 <config name="personconfig"> <!-- <add> --> <!-- 使用addImplicitCollection可以不出现 --> <address> <add>abc;abc<

详解XStream别名

在上一节中,我们已经看到了XStream是多么的简单易用,本文将继续以实例的方式讲解XStream别名.毕竟,你的JAVA对象不可能总是与XML结构毫发无差的,谁也不确定某个开发者手误打错了字母,或者是报文的名称发生了变化. 假设输出如下的XML结构,我们应该怎么做呢? <blog author="一个木瓜">     <entry>       <title>第一篇</title>       <description>欢迎

xStream完美转换XML、JSON

xStream框架 xStream可以轻易的将Java对象和xml文档相互转换,而且可以修改某个特定的属性和节点名称,而且也支持json的转换: 它们都完美支持JSON,但是对xml的支持还不是很好.一定程度上限制了对Java对象的描述,不能让xml完全体现到对Java对象的描述.这里将会介绍xStream对JSON.XML的完美支持.xStream不仅对XML的转换非常友好,而且提供annotation注解,可以在JavaBean中完成对xml节点.属性的描述.以及对JSON也支持,只需要提供