Custom fault handling issue in code-first approach
--------------------------------------------------
Key: AXIS2-3239
URL: https://issues.apache.org/jira/browse/AXIS2-3239
Project: Axis 2.0 (Axis2)
Issue Type: Bug
Affects Versions: 1.3
Environment: winxp, jdk15,
Reporter: Charitha Kankanamge
Priority: Blocker
This issue has been identified and discussed by Jay Zawar in the following
mailing threads.
http://marc.info/?l=axis-user&m=119132155713767&w=2
http://marc.info/?l=axis-user&m=119131613622185&w=2
There seems to be an issue with custom fault handling when code-first approach
is used. Axis2 Faulthandling sample works fine since it is used contract-first
method.
Steps to reproduce:
===============
1. Write the service implementation class which returns a customexception
public class AService {
public long Add(int a, int b, int exceptionThrown) throws CustomException {
if (exceptionThrown != 0) {
System.out.println("CustomException to b
instantiated");
CustomException e = new CustomException();
e.setCustomMsg("bar");
throw e;
}
return a+b;}
}
2. Write CustomeException class
public class CustomException extends java.lang.Exception implements
Serializable{
private static final long serialVersionUID = 1542353156105984960L;
private String customMsg = "This is my error";
public String getCustomMsg() {return customMsg;}
public void setCustomMsg(String customMsg) {this.customMsg= "custom : "
+customMsg;}
}
3. Bundle the service archive correctly and deploy it.
4. Generate ADB client code
5. Write a client
public class Faultclient {
public static void main(String[] args) {
try {
UserTestStub stub;
stub = new
UserTestStub("http://localhost:9764/services/userTest");
UserTestStub.Add req = new UserTestStub.Add();
req.setA(4);
req.setB(5);
req.setExceptionThrown(2);
UserTestStub.AddResponse res;
res = stub.Add(req);
System.out.println(res.get_return());
} catch (AxisFault e1) {
e1.printStackTrace();
e1.getCause();
} catch (CustomExceptionException0 e) {
System.out.println("Error!!!!");
} catch (RemoteException e) {
e.printStackTrace();
}
}
6. I'm always getting 'org.apache.axis2.AxisFault: Exception occurred while
trying to invoke service method Add' error at the client side, though I
expected customexception specified in the service.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]