I've declared an error-page in my web app's web.xml file.    However, sometimes 
my error-page is displayed and sometimes the standard tomcat error page gets 
displayed.    I'm testing my app using JMeter and am trying to see how my app 
behaves under extreme loads.   Specifically, I want to make sure an appropriate 
error page gets displayed when my app's database is too busy to process a 
request.   Since sometimes my error page is displayed, I'm thinking that I've 
declared everything properly.   I'm using Tomcat 5.5.9 and I didn't find this 
problem reported in the Bug Database.


My page uses the following method to obtain a connection to the database:

    private static Connection getConnection()
    {
     try{
          Context initCtx = new InitialContext();
          Context envCtx = (Context) initCtx.lookup("java:comp/env");
 
          DataSource ds = (DataSource)  envCtx.lookup("jdbc/StudyStack");
 
          Connection conn = ds.getConnection();
          return conn ;
      }
      catch ( Throwable throwable ) {
          throw new ConnectionFailedException( throwable );
      }
    }


My ConnectionFailedException class is defined as:

package com.studystack.serverutils;

public class ConnectionFailedException extends RuntimeException {

   public ConnectionFailedException() {
     super();
   }

   public ConnectionFailedException(Throwable cause) {
      super(cause);
   }
}


My web.xml file contains:

<error-page>
    
<exception-type>com.studystack.serverutils.ConnectionFailedException</exception-type>
    <location>/ConnectionFailed.jsp</location>
</error-page>


Sometimes my ConnectionFailed.jsp page gets returned as I'd hope.   But other 
times the following page gets returned:

<html><head><title>Apache Tomcat/5.5.9 - 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;}A.name {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>com.studystack.serverutils.ConnectionFailedException: 
java.sql.SQLException: User root already has more than 'max_user_connections' 
active connections
 
com.studystack.serverutils.StudyStackDatabase.getConnection(StudyStackDatabase.java:70)
 
com.studystack.serverutils.StudyStackDatabase.queryDatabase2(StudyStackDatabase.java:1083)
 org.apache.jsp.StudyTable_jsp._jspService(org.apache.jsp.StudyTable_jsp:370)
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available 
in the Apache Tomcat/5.5.9 logs.</u></p><HR size="1" 
noshade="noshade"><h3>Apache Tomcat/5.5.9</h3></body></html>

--------------------
As you can see from the above results, the exception which I'm trying to catch 
(com.studystack.serverutils.ConnectionFailedException) is being thrown, but 
instead of my page being displayed, the Apache Tomcat error page is being 
displayed.    My assumption is that there is some thread synchronization 
problem; but the tomcat source looks okay to me.


Reply via email to