【问题标题】:JAXB custom exception marshalling errorJAXB 自定义异常编组错误
【发布时间】: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 并没有帮助。我错过了什么?

【问题讨论】:

    标签: java jaxb cxf jax-ws


    【解决方案1】:

    问题是该类缺少设置器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-06
      • 1970-01-01
      • 2019-07-11
      • 2015-10-14
      相关资源
      最近更新 更多