This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Application running on Tomcat handles response.sendError() differently than when on Jetty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Products » Tomcat
Bookmark "Application running on Tomcat handles response.sendError() differently than when on Jetty" Watch "Application running on Tomcat handles response.sendError() differently than when on Jetty" New topic

Application running on Tomcat handles response.sendError() differently than when on Jetty

Rob Ivan

Joined: Jan 07, 2010
Posts: 28

Issue: Application running Apache CXF webservices handles response.sendError() differently when running in Jetty 6.1.21 than in Tomcat 6.0.29 or SpringSource tc Runtime 2.1.0.RELEASE, where as the Jetty response has a status code of HTTP 403 Forbidden and Tomcat has a status code of HTTP 500 Internal Server Error. My client is GWT, and I am trying to detect the HTTP 403 status, which works with the server application running on Jetty but not on Tomcat or SpringSource tc.

Questions: Is this a configuration issue for Tomcat? Do I need to write my own ErrorReportValve implementation?

I have searched various forums (here, and via Google search) for a solution, to no avail. I have tried setting " errorReportValveClass = "" in Tomcat server.xml, and I still get HTTP 500 but with a blank page. I have also tried various settings for cfx.xml to propogate the response status, but that did not work either. I know these are not "Tomcat" changes per se, but I did not want to cross post and Tomcat forum seemed to be the right place to start.

Note: responses captured using Chrome Poster 1.4 running on Google Chrome 8.0.552.224

My application (Spring 3) is generating the following in a Spring Security Filter Bean (extends org.springframework.web.filter.GenericFilterBean):

response.sendError(403, "System Lockout");
throw new WebApplicationException();

Additional configuration details:



<!-- The following two tags configure Spring security. -->


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
xmlns:xsi="" xmlns:jaxrs=""

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<jaxrs:server id="user" address="/">
<ref bean="userResource" />
<entry key="xml" value="application/xml" />
<entry key="json" value="application/json" />


Jetty 6.1.21 Response:

status: 403 System Lockout
Content-Length: 1393
Server: Jetty(6.1.21)
Content-Type: text/html; charset=iso-8859-1
Cache-Control: must-revalidate,no-cache,no-store

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 403 System Lockout</title>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /agency/secure/user. Reason:
<pre> System Lockout</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>;

SpringSource tc Runtime 2.1.0.RELEASE Response (please note that this is about the same response I get from Tomcat, except for the error page--it is still seen as HTTP 500 instead of HTTP 403):

status: 500 Internal Server Error
Date: Fri, 31 Dec 2010 15:48:36 GMT
Content-Encoding: gzip
Connection: close
Content-Length: 793
Vary: Accept-Encoding
Content-Type: text/html;charset=utf-8

<html><head><title>SpringSource tc Runtime 2.1.0.RELEASE/6.0.29.B.RELEASE - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;} {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>$VirtualFilterChain.doFilter($VirtualFilterChain.doFilter($VirtualFilterChain.doFilter($VirtualFilterChain.doFilter($VirtualFilterChain.doFilter($VirtualFilterChain.doFilter(
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the SpringSource tc Runtime 2.1.0.RELEASE/6.0.29.B.RELEASE logs.</u></p><HR size="1" noshade="noshade"><h3>SpringSource tc Runtime 2.1.0.RELEASE/6.0.29.B.RELEASE</h3></body></html>
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Application running on Tomcat handles response.sendError() differently than when on Jetty
jQuery in Action, 3rd edition