Published on Oct 4 2011 in Java Tomcat

If you are getting the following error in your Tomcat server logs "SEVERE: All threads (250) are currently busy, waiting. Increase maxThreads (250) or check the servlet status" then one option is to try to increase maxThreads limit. After the change restart the application server with JCP or command line.

Aside from increasing the maxThreads parameter in ~/appserver/apache-tomcat/conf/server.xml you can also find out what are the threads busy with. You can get a thread dump by pressing the following at the command prompt: Ctrl+\ for Unix/Linux or Ctrl+Break for Windows machines. If you are running your application as a background process in Linux, you could execute kill -QUIT from another command prompt. The above signals the VM to generate a full thread dump. Sun's VM prints the dump on the error stream while IBM's JDK generates a new file with the thread dump every time you send the signal. To check what are the threads busy with login to your account via SSH. You will need to identify your java process ID <VMPID>. Run:

cd ~/appservers/apache-tomcat/logs
cp catalina.out catalina.out.bak 
ps x
kill -QUIT <VMPID>
grep '^"' catalina.out | sort

Thread dump will go by default into catalina.out.