I am
trying to configure Resin to use a custom 500 servlet exception page, rather
than the default supplied by Resin.
I
have tried two different lines in web.xml, which from reading the FAQ and the
reference materials, seem to be all I need to do in order to get this to work:
<error-page error-code='500'
location='/gbn_500_error.jsp'/>
or
<error-page exception-type='javax.servlet.ServletException'
location='/gbn_500_error.jsp'/>
When
I supply a servlet name in the URL that does not exist in our application, I
get the following output:
javax.servlet.ServletException: Class `ConversationsddHomeDisplayServlet.srv'
was not found in classpath.
Classes normally belong in /gbn/WEB-INF/classes.
at com.caucho.server.http.Application.instantiateServlet(Application.java:3191)
at com.caucho.server.http.Application.createServlet(Application.java:3099)
at com.caucho.server.http.Application.loadServlet(Application.java:3060)
at com.caucho.server.http.QServletConfig.loadServlet(QServletConfig.java:435)
at com.caucho.server.http.Application.getFilterChainServlet(Application.java:2804)
at com.caucho.server.http.Invocation.service(Invocation.java:311)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:225)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:106)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:83)
at com.marketspace.mea.common.servlet.DispatcherBaseServlet.doPost(DispatcherBaseServlet.java:97)
at com.marketspace.mea.common.servlet.DispatcherBaseServlet.doGet(DispatcherBaseServlet.java:63)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:536)
which
is correct behavior. Looking through the source code I can see that the ServletException
thrown is caught on line 3099 of the com.caucho.server.http.Application object.
To
me, the custom 500 should work like a custom 404 page. I
have successfully implemented a custom 404 by do the same sort of thing:
<error-page error-code='404'
location='/gbn_404_error.jsp'/>
The
code also catches an application-specific data access exception in our display servlet,
and on error, call this base case class method set the appropriate error code
in the response object:
protected ProcessingStatus do404Redirect(HttpServletRequest
request, HttpServletResponse response)
{
ProcessingStatus
returnValue = ProcessingStatus.SUCCESS;
try
{
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} catch(IOException e)
{
// shouldn't happen
handleException(request, e);
returnValue = ProcessingStatus.FAILURE;
}
return
returnValue;
}
Doing
so, we are able to use a custom 404 page. If no error code is set in the response
object, Resin will correctly display a 500 servlet error.
I am
wondering if anybody else had run into this issue. My guess is that Resin
is not properly checking the web.xml for custom 500 errors specified there and
is not allowing the display of a custom page.
Currently,
we are using Resin 2.1.8.
Any
help would be greatly appreciated.
::
:: greg robinson
:: grobinson@xxxxxxxxxxxxxxxxxxxxx
:: t 617-252-2672 : m 617-792-3254
::
:: marketspace®
:: two canal park : cambridge, ma 02141
:: www.marketspaceglobal.com
:: marketspace®, a member of monitor group
::