Logging different log levels to different appenders with logback

Assume a scenario where you want debug messages to be logged a different file than the main one that captures messages above info log level. The way to configure this is quite different especially when you come from a log4j background.

Read the rest of this entry

Troubleshooting file leaks in java applications

Recently I was diagnosing a production issue related file handle leaks. The setup was as follows – There were two applications. Application A was an ETL process that loaded the input file into the system and Application B that deleted these input files after A completes. Application B randomly failed with an error that stated that the file was still being used by another process.

Read the rest of this entry

Identifying jar dependencies

Recently I had to find dependencies between the jar files included in my web application and I came across JBoss Tattletale! Its a tool that does many things including finding jar dependencies


It generates reports as HTML files. The main HTML file is index.html. The reports include following details.


Log input parameters for a Spring StoredProcedure

To view the input parameters passed to an SP through Spring StoredProcedure, enable TRACE log level for org.springframework.jdbc.core.StatementCreatorUtils class. The SP parameters are logged by the setParameterValueInternal() method.

This is in sync with spring version 3.2.

Issues with Spring’s ResourceBundleMessageSource

In Spring, you can use ResourceBundleMessageSource to resolve text messages from properties file, based on the selected locales. Follow this link for an introductory example on how to do so.

This post details on two bottlenecks with this message source’s implementation that we encountered through load tests.

Read the rest of this entry

Scheduling a batch file every 10 seconds

Recently while investigating high cpu issues in an web application, I wanted to take thread dumps (through jstack) every 10 seconds. First thought was to schedule the batch file through a task scheduler, but I realized that with the task scheduler you cannot set a repetition interval lower then a minute.

An alternative approach would be to use a ping command in the batch file.

Read the rest of this entry

Detecting connection leaks with tomcat connection pool

Tomcat’s JDBC connection pool can help you detect connection leaks in your web application. It provides the below three attributes in order to do this


(boolean) Flag to remove abandoned connections if they exceed the removeAbandonedTimout. If set to true a connection is considered abandoned and eligible for removal if it has been in use longer than the removeAbandonedTimeout Setting this to true can recover db connections from applications that fail to close a connection. See also logAbandoned The default value is false.
removeAbandonedTimeout (int) Timeout in seconds before an abandoned(in use) connection can be removed. The default value is 60 seconds. The value should be set to the longest running query your applications might have.
logAbandoned (boolean) Flag to log stack traces for application code which abandoned a Connection. Logging of abandoned Connections adds overhead for every Connection borrow because a stack trace has to be generated. The default value is false.

Spring commits on NOT_SUPPORTED propagation level

If you are working with spring and executing a DML query inside a transaction which has a propagation level of NOT_SUPPORTED, you might get surprised that the DML query gets committed despite the fact that the propagation level is NOT_SUPPORTED.

Read the rest of this entry

Jstack Error – Not enough storage available

JStack is nice tool to print thread stack traces for a given java process. It comes to be very handy when analyzing high cpu usage problems. At times when executing this command you may encounter an error like I did🙂

“Not enough storage is available to process this command”

It appears that on Windows Vista and later jstack doesn’t work because the command might be executed from a different user account then the one under which the jvm is running. The error doesn’t have anything to do with memory. So possible solutions to this are

  1. Run jstack under the same account as the jvm
  2. Use psexec to execute the jstack command like
psexec -s "%JAVA_HOME%\bin\jstack.exe" PID >stack.txt

Hope that helps !

Find Apache Web Server Version

Below are a couple of ways to figure out the apache web server version (on either windows or linux)

1. Simplest – execute the command  “httpd -v”. httpd is the Apache HyperText Transfer Protocol (HTTP) server program.

Sample output –
Server version: Apache/2.2.17 (Win32)
Server built: Oct 18 2010 01:58:12

This would require you to login to the web server machine or putty it (in case of linux)

2. Telnet