I have created a custom exception class to handle all my project's errors.
It's linked to a SOAP web service, that's why there is @WebFault.
GTWException class
@WebFault(name = "GTWFaultBean", targetNamespace = "http://www.raiffeisen.lu")
public class GTWException extends Exception implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 6512673270706929264L;
private String errorDescription;
private String errorLocation;
public GTWException(String errorDescription){
super();
this.errorDescription = errorDescription;
}
public GTWException(String errorDescription, String errorLocation) {
super();
this.errorDescription = errorDescription;
this.errorLocation = errorLocation;
}
public String getException()
{
String error = "location:"+errorLocation+"|*SEP*|"+"description:"+errorDescription;
return error;
}
public int getExceptionId()
{
int exceptionId = 1;
if(errorDescription!=null)
{
exceptionId = 0;
}
return exceptionId;
}
public static String toString(Throwable th) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
th.printStackTrace(pw);
return sw.toString();
}
}
GTWFaultBean class
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "GTWFaultBean", propOrder = {
"errorMessage"
})
public class GTWFaultBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2774168704928329294L;
private String errorMessage;
private String errorCode;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
}
Here is my console output
exception.GTWException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createUserDefinedException(SOAPFaultBuilder.java:309)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:130)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:135)
at com.sun.proxy.$Proxy10.create(Unknown Source)
at controller.WSconsumer.consumeWS(WSconsumer.java:69)
at controller.WSconsumer.main(WSconsumer.java:87)
I searched a lot by myself but I couldn't figure the problem out.
What am I Doing wrong ?