You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Iain Sanderson <sa...@mc.duke.edu> on 2003/04/03 19:31:50 UTC

Tomcat unstable - Dr. Watson. Why?

Hello,

Tomcat is crashing on my  application server when my database server is 
busy with a running backup, which is every night from 12am to 7am ( 80 
Gb).

I'm running Tomcat 4.22 on Windows NT sp6  using the Java 1.41 VM as a 
service with the  -Xxms256m -Xxmx256m  switches set in the registry for 
the VM. (This is the same as setting these options in Catalina Opts when 
you're not running Tomcat as a service).

Tomcat.exe is throwing a Dr. Watson error

"Application exception occurred:
        App:  (pid=603)                   ----->which is tomcat.exe
        When: 4/3/2003 @ 1:45:16.203
        Exception number: c0000005 (access violation)
"
There is no information in Tomcat's logs at all.  Windows just shuts down 
the Tomcat service. Tomcat remains unstable like this as long as my 
database server  ( a different and very powerful box) is backing up.
Here are some clues:-

a) This instability is cured by enabling incremental garbage collection  ( 
-Xincgc JVM switch), but performance reduces by 300%. Our SQL  queries on 
the server  are large ( Operating room schedules etc. Queries take 0.15 to 
0.2 seconds, but page refreshes in Tomcat  5-6 seconds, which is 
acceptable. With incremental GC this increases to 17 seconds, which is 
not.)

I'm sure the problem is due to database connections, but I can't fault my 
code. I'm using Tomcat's JNDI datasource pool (commons DBCP), set in 
server.xml.  I have been very careful to close all my connections using 
the following code straight out of Tomcat's documentation (see below)

Can anybody help? I've been chasing this for some time now and have lost 
most of my hair.

Iain

Below is datasource configuration from web-app context in server.xml and 
sample of database connection code.

code.


Connection conn = null;
  Statement stmt = null;  // Or PreparedStatement if needed
  ResultSet rs = null;
  try {
    conn = ... get connection from connection pool ...
    stmt = conn.createStatement("select ...");
    rs = stmt.executeQuery();
    ... iterate through the result set ...
    rs.close();
    rs = null;
    stmt.close();
    stmt = null;
    conn.close(); // Return to connection pool
    conn = null;  // Make sure we don't close it twice
  } catch (SQLException e) {
    ... deal with errors ...
  } finally {
    // Always make sure result sets and statements are closed,
    // and the connection is returned to the pool
    if (rs != null) {
      try { rs.close(); } catch (SQLException e) { ; }
      rs = null;
    }
    if (stmt != null) {
      try { stmt.close(); } catch (SQLException e) { ; }
      stmt = null;
    }
    if (conn != null) {
      try { conn.close(); } catch (SQLException e) { ; }
      conn = null;
    }
  }





 Server.xml Settings are:-
<ResourceParams name="jdbc/saturn">
            <parameter>
              <name>factory</name>
 <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
            </parameter>
            <parameter>
              <name>maxActive</name>
              <value>100</value>
            </parameter>
            <parameter>
              <name>maxWait</name>
              <value>100000</value>
            </parameter>
            <parameter>
              <name>password</name>
              <value></value>
            </parameter>
            <parameter>
              <name>url</name>
              <value>jdbc:sybase:Tds:</value>
            </parameter>
            <parameter>
              <name>driverClassName</name>
              <value>com.sybase.jdbc2.jdbc.SybDriver</value>
            </parameter>
            <parameter>
              <name>maxIdle</name>
              <value>30</value>
            </parameter>
            <parameter>
              <name>username</name>
              <value></value>
            </parameter>
            <parameter>
              <name>removeAbandoned</name>
              <value>true</value>
            </parameter>
           <parameter>
              <name>removeAbandonedTimeout</name>
              <value>120</value>
            </parameter> 
            <parameter>
              <name>logAbandoned</name>
              <value>false</value>
            </parameter>
            <parameter>
              <name>validationQuery</name>
              <value>SELECT * FROM "dev_team"."VersionInfo"</value>
            </parameter> 
          </ResourceParams>