java.util.Map is an interface, and JAXB can't handle interfaces.

来源:互联网 发布:国外的神秘组织知乎 编辑:程序博客网 时间:2024/05/16 06:52

原理参考: http://blog.sina.com.cn/s/blog_adc54a3b0101cn3h.html

处理方式推荐:http://blog.csdn.net/kongxx/article/details/7544640

不推荐:http://jyao.iteye.com/blog/1213655

java.util.Map is an interface, and JAXB can't handle interfaces.

 

在webservice项目中,出现异常:

Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException

 

仔细查看程序中 一段详细错误信息:
java.sql.Timestamp does not have a no-arg default constructor.
 this problem is related to the following location:
  at java.sql.Timestamp
  at public java.sql.Timestamp

 

===============网上查看类似解决方法===========================

网上搜索结果为:

class路径里面只有1个asm和1个cglib-NODEP-2.1_3.JAR
准确得说cglib还是在看了willem得回帖后加上去得,唯一得asm-2.2.3.jar也来自cxf。
cxf的jar包出现问题~~
=======================================================
但是我的程序,之前是正常可以运行、部署 在接口中增加方法不存在jar包冲突导致问题出现
在根据apache官网资料和网上资料指示:apache开源CXF虽然比较小型的简单的的webservice开发,但是有些数据类型支持不好
在项目中使用Apache开源的Services Framework CXF来发布WebService,发布的接口的入参有些类型支持不是很好,比如Timestamp和Map。这个时候我们就需要编写一些适配来类型转换(Timestamp为例:类型转换Timestamp和String)
在Timestamp注解:@XmlJavaTypeAdapter(Timestamp适配对象.class)

 

Timestamp适配对象中:Timestamp转换为String类型输出,传入String时候,转换以Timestamp类型存入

同理Map也需要转换

 

 

 

0 0
原创粉丝点击