I have a library containing beans that are passed between the server and the client application. It also contains a custom exception class:
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;
}
}
When the server throws the exception, this happens on the client:
org.apache.cxf.interceptor.Fault: Marshalling Error: MyServiceException.<init>(java.lang.String)
..........
Caused by: java.lang.NoSuchMethodException: MyServiceException.<init>(java.lang.String)
if I add a no-arg constructor to the exception class it works, but the code and description fields are 0 and null. They are however present in the super class detailsMessage. I don't have this problem with any of the other beans. Implementing Serializable did not help. What am I missing?
Problem was that the class was missing setters.