Apache Tomcat

To make users as Tomcat admins

Add the following to tomcat-users.xml

<role rolename="manager"/>
<user username="reza" password="rezareza" roles="manager"/>

Log4j for Tomcat 6

Just copy your log4j.xml under lib folder of Tomcat and restart. This can be shared by all the applications in this Tomcat.

Using Tomcat\lib folder

Avoid using this folder. Keep application jar files in WEB-INF\lib. Putting jar files into this shared folder might make things complicated in class loading point of view. But if you have to do this (lack of space, RAM, bandwidth, etc.) then write code in a way that it can run in a shared environment, avoid static members, be careful when the code is statefull, etc. Read: http://stackoverflow.com/questions/267953/managing-libraries-in-tomcat.

Broken Pipe error

Looks as if someone is making a request then disconnecting before the server can hand the response back. That is why the server might be getting a Broken pipe: can't write the response back on the socket because the client has disconnected. Sometimes running load testers such as JMeter cause this.

Debug Mode

"catalina.sh jpda start" in Linux or "catalina.bat jpda start" in Windows.


In Windows use catalina run instead of catalina start to stop Tomcat from opening in the a new window. This will keep it in the same window.

Session timeout

The default session timeout of tomcat is 30 minutes. If you need more add: <session-config> <session-timeout>30</session-timeout> </session-config>


  • Run Tomcat in JVM -server mode for better server performance.
  • set Java options (export JAVA_OPTS="-XX:MaxPermSize=128m -Xms64m -Xmx256m -server") to apply to all Java processes or just CATALINA_OPTS only for Tomcat
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License