You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2006/04/28 12:38:42 UTC
svn commit: r397845 - in /webservices/axis2/trunk/java/modules:
core/conf/axis2.xml core/src/org/apache/axis2/deployment/axis2_default.xml
core/src/org/apache/axis2/engine/AxisEngine.java
integration/test/org/apache/axis2/rpc/MultirefTest.java
Author: chinthaka
Date: Fri Apr 28 03:38:41 2006
New Revision: 397845
URL: http://svn.apache.org/viewcvs?rev=397845&view=rev
Log:
If there aren't any information available to find out the fault reason, we set the message of the expcetion as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be wrapped by different levels. Due to this the initial exception message can be lost. This commit will fix that with a flag and if it is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.
Modified:
webservices/axis2/trunk/java/modules/core/conf/axis2.xml
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
Modified: webservices/axis2/trunk/java/modules/core/conf/axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/conf/axis2.xml?rev=397845&r1=397844&r2=397845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/core/conf/axis2.xml Fri Apr 28 03:38:41 2006
@@ -5,7 +5,16 @@
<parameter name="hotdeployment" locked="false">true</parameter>
<parameter name="hotupdate" locked="false">false</parameter>
<parameter name="enableMTOM" locked="false">false</parameter>
+
+ <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
+ <!--that behaviour.-->
<parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+
+ <!--If there aren't any information available to find out the fault reason, we set the message of the expcetion-->
+ <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+ <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+ <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+ <parameter name="DrillDownToRootCauseForFaultReason" locked="false">false</parameter>
<!-- Uncomment this to enable REST support -->
<!-- <parameter name="enableREST" locked="false">true</parameter>-->
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml?rev=397845&r1=397844&r2=397845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml Fri Apr 28 03:38:41 2006
@@ -5,12 +5,21 @@
<parameter name="hotdeployment" locked="false">true</parameter>
<parameter name="hotupdate" locked="false">false</parameter>
<parameter name="enableMTOM" locked="false">false</parameter>
+
+ <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
+ <!--that behaviour.-->
<parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+ <!--If there aren't any information available to find out the fault reason, we set the message of the expcetion-->
+ <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+ <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+ <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+ <parameter name="DrillDownToRootCauseForFaultReason" locked="false">false</parameter>
+
<!-- Uncomment this to enable REST support -->
<!-- <parameter name="enableREST" locked="false">true</parameter>-->
-
+ <!--This is the user name and password of admin console-->
<parameter name="userName" locked="false">admin</parameter>
<parameter name="password" locked="false">axis2</parameter>
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java?rev=397845&r1=397844&r2=397845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java Fri Apr 28 03:38:41 2006
@@ -350,7 +350,10 @@
fault.setReason((SOAPFaultReason) faultElementsMap.get(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME));
} else {
message = axisFault.getReason();
- message = message != null && "".equals(message) ? message : e.getMessage();
+ if (message == null || "".equals(message)) {
+ message = getFaulReasonFromException(e, context);
+ }
+// message = message != null && "".equals(message) ? message : e.getMessage();
}
@@ -399,15 +402,15 @@
if (faultElementsMap != null && faultElementsMap.get(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME) != null)
{
fault.setDetail((SOAPFaultDetail) faultElementsMap.get(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME));
- }else {
+ } else {
OMElement detail = axisFault.getDetail();
if (detail != null) {
fault.getDetail().addDetailEntry(detail);
- }else if(sendStacktraceDetailsWithFaults){
+ } else if (sendStacktraceDetailsWithFaults) {
fault.setException(axisFault);
}
}
- }else if (fault.getException() == null && sendStacktraceDetailsWithFaults) {
+ } else if (fault.getException() == null && sendStacktraceDetailsWithFaults) {
if (e instanceof Exception) {
fault.setException((Exception) e);
} else {
@@ -419,6 +422,24 @@
}
/**
+ * By the time the exception comes here it can be wrapped by so many levels. This will crip down
+ * to the root cause and get the initial error depending on the property
+ *
+ * @param e
+ */
+ private String getFaulReasonFromException(Throwable e, MessageContext context) {
+ Throwable throwable = e;
+ Parameter param = context.getParameter("DrillDownToRootCauseForFaultReason");
+ boolean drillDownToRootCauseForFaultReason = param != null && ((String) param.getValue()).equalsIgnoreCase("true");
+ if (drillDownToRootCauseForFaultReason) {
+ while (throwable.getCause() != null) {
+ throwable = throwable.getCause();
+ }
+ }
+ return throwable.getMessage();
+ }
+
+ /**
* This methods represents the inflow of the Axis, this could be either at the server side or the client side.
* Here the <code>ExecutionChain</code> is created using the Phases. The Handlers at the each Phases is ordered in
* deployment time by the deployment module
@@ -652,7 +673,7 @@
private TransportSender sender;
public TransportNonBlockingInvocationWorker(MessageContext msgctx,
- TransportSender sender) {
+ TransportSender sender) {
this.msgctx = msgctx;
this.sender = sender;
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java?rev=397845&r1=397844&r2=397845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java Fri Apr 28 03:38:41 2006
@@ -300,6 +300,7 @@
fail("This should fail with : " + "org.apache.axis2.AxisFault: Invalid reference :2");
} catch (AxisFault axisFault) {
String val = axisFault.getFaultDetailElement().toString();
+ System.out.println("val = " + val);
int index = val.indexOf("org.apache.axis2.AxisFault: Invalid reference :2");
if (index < 0) {
fail("This should fail with : " + "org.apache.axis2.AxisFault: Invalid reference :2");