【发布时间】:2016-09-02 09:41:48
【问题描述】:
我有一个包含在服务器和客户端应用程序之间传递的 bean 的库。它还包含一个自定义异常类:
public class MyServiceException extends Exception{
private int code;
private String description;
public MyServiceException(int code, String description){
super(code + ": " + description);
this.code = code;
this.description = description;
}
public int getCode() {
return code;
}
public String getDescription() {
return description;
}
}
当服务器抛出异常时,这发生在客户端:
org.apache.cxf.interceptor.Fault: Marshalling Error: MyServiceException.<init>(java.lang.String)
..........
Caused by: java.lang.NoSuchMethodException: MyServiceException.<init>(java.lang.String)
如果我将一个无参数构造函数添加到它可以工作的异常类,但代码和描述字段是 0 和 null。然而,它们存在于超类 detailsMessage 中。我对任何其他豆子都没有这个问题。实现 Serializable 并没有帮助。我错过了什么?
【问题讨论】: