How to monitor connection pool in SAP NetWeaver Java AS

Another interesting day today. And another experience with SAP NetWeaver Java application server. Our application (Vendavo of course) suffered with intermittent database connection problems in one of the customer environments. Like in many other cases, also in this case Vendavo is deployed to SAP NetWeaver Java stack.

In the application log files we found next exception stack trace from SAP NetWeaver:

Caused by: ResourceException in method ConnectionFactoryImpl.getConnection(): Cannot get connection for 60 seconds. Possible reasons: 1) Connections are cached within SystemThread(can be any server service or any code invoked within SystemThread in the SAP J2EE Engine), 2) The pool size of adapter „productionPool“ is not enough according to the current load of the system or 3) The specified time to wait for connection is not enough according to the pool size and current load of the system. In case 1) the solution is to check for cached connections using the Connector Service list-conns command, in case 2) to increase the size of the pool and in case 3) to increase the time to wait for connection property. In case of application thread, there is an automatic mechanism which detects unclosed connections and unfinished transactions. at at com.vendavo.core.omi.JDBCHelper.getConnection( … 36 more

More details about this exception can be found at
After we verified that Oracle parameters PROCESSES and SESSIONS are set to sufficient values we came to conclusion that problem is in NetWeaver database connection pool, where the limits are hit. And that the most probable cause of the problem is connection leak. Somewhere database connections are not properly closed.
I found that SAP NetWeaver Java App server contains very nice connection pool monitor in its Visual Administrator. Real-time chart displays number of used / free connections in the pool.
We found that after a particular business action is invoked, limit of connections in the pool is hit almost immediately. Next figure shows that pool does not have any more free connections. All 100 connections are used.

We were able to find the code where the connection was not closed properly pretty quickly and the fix was easy. Next picture shows the same bussiness operation after we applied the fix:

I really appreciate the idea having the real-time connection pool monitor in Visual Administrator.
Btw. if you ever wondered where the connection pool is configured (maximum connections, initial connections etc.), it’s in the Additional tab of the given data source in the Visual Administrator:
Visual Administrator / Server / Services / JDBC Connector / Resources / Data Source

Local SMTP server for testing of email notifications

Testing of the email notifications – i.e. tests that business application is sending appropriate emails to right people is pretty boring but important part of the development of business applications. Developers are tend to underestimate this part of functionality.
Btw. although this piece of work is usually very simple, there’s very often a funny story linked to it. I can tell you several funny stories how hundreds of real users accross the globe were spammed from development environment with purchase orders, invitation to auctions or requirements for approval. This happened at least once in every company I worked for 😉
The best idea is to setup local SMTP server and use it instead of corporate one. And of course be careful to not allow the test emails to be sent to real users.

Recently my colleague @nemecpav showed me this ultra-simple application called Antix SMTP Server for Developers. This application is so simple, that I was even not able to find a way to configure for example a port where SMTP is listening. But at the end, why do would I need to change it?

And this application does the job perfectly. Zero configuration, just run it. And its free.

It’s running in a try, listening on SMTP port and behaves like a folder where all outgoing emails are placed. It’s a folder, so you can switch views in an explorer-like manner.

You can open the outgoing emails in the email client to verify the content, headers etc.

And finally – you do not need to worry that your test email will reach the real users 🙂