Nicholas Palm created AXIS2-5514:
------------------------------------
Summary: Fault message lost within fault recreation of autogen
stub class
Key: AXIS2-5514
URL: https://issues.apache.org/jira/browse/AXIS2-5514
Project: Axis2
Issue Type: Bug
Reporter: Nicholas Palm
If a fault is thrown and caught to be rethrown within an autogenerated stub
class, the original message on the AxisFault is lost. The current
implementation uses the default constructor which does not factor in the
original message.
Example:
catch(org.apache.axis2.AxisFault f){
org.apache.axiom.om.OMElement faultElt = f.getDetail();
if (faultElt!=null){
if (faultExceptionNameMap.containsKey(new
org.apache.axis2.client.FaultMapKey(faultElt.getQName(),"SomeMethod"))){
//make the fault by reflection
try{
java.lang.String exceptionClassName =
(java.lang.String)faultExceptionClassNameMap.get(new
org.apache.axis2.client.FaultMapKey(faultElt.getQName(),"SomeMethod"));
java.lang.Class exceptionClass =
java.lang.Class.forName(exceptionClassName);
java.lang.Exception ex = (java.lang.Exception)
exceptionClass.newInstance();
//message class
java.lang.String messageClassName =
(java.lang.String)faultMessageMap.get(new
org.apache.axis2.client.FaultMapKey(faultElt.getQName(),"SomeMethod"));
java.lang.Class messageClass =
java.lang.Class.forName(messageClassName);
java.lang.Object messageObject =
fromOM(faultElt,messageClass,null);
java.lang.reflect.Method m =
exceptionClass.getMethod("someMethod",
new
java.lang.Class[]{messageClass});
m.invoke(ex,new
java.lang.Object[]{messageObject});
if (ex instanceof somePath.autogen.SomeFault1){
throw (somePath.autogen.SomeFault1)ex;
}
if (ex somePath.autogen.SomeFault2){
throw (somePath.autogen.SomeFault2)ex;
}
if (ex somePath.autogen.SomeFault3){
throw (somePath.autogen.SomeFault3)ex;
}
throw new
java.rmi.RemoteException(ex.getMessage(), ex);
}catch(java.lang.ClassCastException e){
// we cannot intantiate the class - throw the
original Axis fault
throw f;
} catch (java.lang.ClassNotFoundException e) {
// we cannot intantiate the class - throw the
original Axis fault
throw f;
}catch (java.lang.NoSuchMethodException e) {
// we cannot intantiate the class - throw the
original Axis fault
throw f;
} catch (java.lang.reflect.InvocationTargetException e)
{
// we cannot intantiate the class - throw the
original Axis fault
throw f;
} catch (java.lang.IllegalAccessException e) {
// we cannot intantiate the class - throw the
original Axis fault
throw f;
} catch (java.lang.InstantiationException e) {
// we cannot intantiate the class - throw the
original Axis fault
throw f;
}
}else{
throw f;
}
}else{
throw f;
}
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]