Error at method initiateBatchProcess : unreported exception must be caught or declared to be thrown. I have a custom exception class with @webFault annotation to handle jaxb exception as suggested in this link.
My initiateBatchProcess()
method is already extending custom exception class but still its showing error
@WebService(serviceName = "WT_WebService")
public class WT
{
ResponseInfo result = new ResponseInfo();
@WebMethod(operationName = "initiateBatchProcess")
public @WebResult(name = "Response") ArrayList initiateBatchProcess(@WebParam (name = "BatchID")int BatchId, @WebParam (name = "MPTRef")String MPTRef) throws MyServiceException
{
return result.initiateBatchProcess();
}
Custom Exception class:
@WebFault(name="MyServiceException", faultBean = "com.ws.MyServiceFault", targetNamespace="http://wataniya.com/")
public class MyServiceException extends Exception {
private static final long serialVersionUID = 1L;
private MyServiceFault faultBean;
public MyServiceException() {
super();
}
public MyServiceException(String message, MyServiceFault faultBean, Throwable cause) {
super(message, cause);
this.faultBean = faultBean;
}
public MyServiceException(String message, MyServiceFault faultBean) {
super(message);
this.faultBean = faultBean;
}
public MyServiceFault getFaultInfo() {
return faultBean;
}
}
FaultBean class:
public class MyServiceFault {
/**
* Fault Code
*/
private String faultCode;
/**
* Fault String
*/
private String faultString;
/**
* @return the faultCode
*/
public String getFaultCode() {
return faultCode;
}
/**
* @param faultCode the faultCode to set
*/
public void setFaultCode(String faultCode) {
this.faultCode = faultCode;
}
/**
* @return the faultString
*/
public String getFaultString() {
return faultString;
}
/**
* @param faultString the faultString to set
*/
public void setFaultString(String faultString) {
this.faultString = faultString;
}
}
ResponseInfo Class:
public class ResponseInfo
{
static Properties props = new Properties();
public ArrayList initiateBatchProcess() throws Exception
{
ArrayList list = new ArrayList();
props.load(ResponseInfo.class.getResourceAsStream("ResponseFields.properties"));
String method1_status = props.getProperty("method1_status");
String method1_comments = props.getProperty("method1_comments");
list.add(method1_status);
list.add(method1_comments);
return list;
}
}