geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r681593 - /geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
Date Fri, 01 Aug 2008 02:50:13 GMT
Author: gawor
Date: Thu Jul 31 19:50:13 2008
New Revision: 681593

URL: http://svn.apache.org/viewvc?rev=681593&view=rev
Log:
no need to log every exception as an error

Modified:
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java?rev=681593&r1=681592&r2=681593&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
Thu Jul 31 19:50:13 2008
@@ -32,6 +32,7 @@
 import javax.xml.ws.handler.Handler;
 
 import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingHelper;
 import org.apache.axis2.addressing.EndpointReference;
@@ -202,39 +203,43 @@
             msgContext.setAxisService(this.service);
             
             doService2(request, response, msgContext);
-        } catch (Throwable e) {
+        } catch (AxisFault e) {
+            LOG.debug(e.getMessage(), e);
+            handleFault(msgContext, response, e);
+        } catch (Throwable e) {            
             String msg = "Exception occurred while trying to invoke service method doService()";
             LOG.error(msg, e);
-            try {
-                AxisEngine engine = new AxisEngine(this.configurationContext);
+            handleFault(msgContext, response, new AxisFault(msg, e));
+        }
 
-                msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
-                msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, new Axis2TransportInfo(response));
+    }
 
-                MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext,
e);
-                // If the fault is not going along the back channel we should be 202ing
-                if (AddressingHelper.isFaultRedirected(msgContext)) {
-                    response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED);
-                } else {
-                    response.setStatusCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
-                }
-                engine.sendFault(faultContext);
-            } catch (Exception ex) {
-                if (AddressingHelper.isFaultRedirected(msgContext)) {
-                    response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED);
-                } else {
-                    response.setStatusCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
-                    response.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/plain");
-                    PrintWriter pw = new PrintWriter(response.getOutputStream());
-                    ex.printStackTrace(pw);
-                    pw.flush();
-                    LOG.error(msg, ex);
-                }
-            }
+    private void handleFault(MessageContext msgContext, Response response, AxisFault e) {
+        // If the fault is not going along the back channel we should be 202ing
+        if (AddressingHelper.isFaultRedirected(msgContext)) {
+            response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED);
+        } else {
+            response.setStatusCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
         }
+        
+        msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
+        msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, new Axis2TransportInfo(response));
 
+        try {
+            MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext,
e);
+            AxisEngine.sendFault(faultContext);
+        } catch (Exception ex) {
+            LOG.warn("Error sending fault", ex);
+            if (!AddressingHelper.isFaultRedirected(msgContext)) {
+                response.setStatusCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
+                response.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/plain");
+                PrintWriter pw = new PrintWriter(response.getOutputStream());
+                ex.printStackTrace(pw);
+                pw.flush();
+            }
+        }
     }
-
+    
     protected String getServicePath(String contextRoot) {
         String location = this.portInfo.getLocation();
         if (location != null && location.startsWith(contextRoot)) {



Mime
View raw message