Tomcat Tips

java.lang.OutOfMemoryError: PermGen space

This error seems to occur if using CGLIB and the Sun JVM under Tomcat. A lump of PermGen memory space is lost each time an application is deployed. It can be alleviated by increasing the maximum amount of memory available for the PermGen memory space. Add the following option to the JVM arguments in Note: This option only applies to the Sun JVM. The options are likely to differ for other JVM implementations.

JAVA_OPTS="$JAVA_OPTS -Xmx256m -XX:MaxPermSize=128m"

or even better, try these options which alleviate the problem considerably

JAVA_OPTS="$JAVA_OPTS -Xmx256m  -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=128m"


URI Encoding

Tomcat's default URI encoding is ISO-8859-1. To change this to UTF-8, add an URIEncoding attribute of 'UTF-8' to server.xml.

<Server ... >


  <Service name="Catalina">


      <Connector port="8080" maxHttpHeaderSize="8192"
                    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                    enableLookups="false" redirectPort="8443" acceptCount="100"
                    connectionTimeout="20000" disableUploadTimeout="true" 

More information at

Debian Tomcat 5.5


Ordinarily, Tomcat redirects all text written to stdout to catalina.out. The Debian 4.0 (Etch) Tomcat package redirects catalina.out to catalina_yyyy-mm-dd.log and uses logrotate to rotate the logs.

/var/lib/tomcat55/conf/ controls what is written to separate logs for each class-loader using java util logging. See the Tomcat documentation on logging to change the configuration.

In general, if you want to see stdout, tail catalina_yyyy-mm-dd.log (note the underscore), but if you only want to monitor Tomcat, tail catalina.yyyy-mm-dd.log (note the dot). If an application fails to deploy, look in localhost.yyyy-mm-dd.log for error messages.

Use log4j in your own application, and tail the specific log to debug your application.

See 'Taxonomy of class loader problems encountered when using Jakarta Commons Logging' re classloading problems with Apache Commons Logging

Mail Server Configuration

Suppressing Stack Traces on HTTP 500 Errors


-- Frank Dean - 18 Jul 2011

-- Frank Dean - 29 Aug 2007