遇到jaxb框架的一个坑 只能发射类不能反射interface

1 篇文章 0 订阅
@xmlElement
标有的对象必须是要class类型,不能是interface

[quote]


public static String marshal(Object obj) {
OutputStream os = new ByteArrayOutputStream();
String xmlStr = null;
try {
createContext(obj.getClass()).createMarshaller().marshal(obj, os);
xmlStr = os.toString();
} catch (JAXBException e) {
String errorMsg = "Failed to parse the object to xml string with error: " + e.getMessage();
LOGGER.error(errorMsg);
throw new SerializeException(errorMsg, e);
} finally {
if (os != null) {
os = null;
}
}
return xmlStr;
}


createContext(obj.getClass()).createMarshaller().marshal(obj, os);





com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
java.io.Serializable is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at java.io.Serializable
at private java.io.Serializable[] com.statestr.gcth.application.model.DashBoardEvent.dashboardEventParams
at com.statestr.gcth.application.model.DashBoardEvent
at private com.statestr.gcth.application.model.DashBoardEvent com.statestr.gcth.application.model.GcRemediationTask.dashBoardEvent
at com.statestr.gcth.application.model.GcRemediationTask
java.io.Serializable does not have a no-arg default constructor.
this problem is related to the following location:
at java.io.Serializable
at private java.io.Serializable[] com.statestr.gcth.application.model.DashBoardEvent.dashboardEventParams
at com.statestr.gcth.application.model.DashBoardEvent
at private com.statestr.gcth.application.model.DashBoardEvent com.statestr.gcth.application.model.GcRemediationTask.dashBoardEvent
at com.statestr.gcth.application.model.GcRemediationTask


[/quote]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值