WebSphere interview question · Most asked
Users see errors and the logs show J2CA0045E: connection not available. How do you investigate?
Scenario
Summary
J2CA0045E means a request waited the full connection timeout for a pooled database connection and none became free: the pool is exhausted. Find out why connections are held: slow queries, long transactions, connection leaks (code that never closes connections), a downstream call made while holding a connection, or a pool too small for the load. Raising the maximum without understanding the cause usually just moves the problem to the database.
Longer Answer
- Pool metrics: PMI JDBC counters (pool size, free pool size, wait time, use time) or Liberty's
ConnectionPoolmetrics throughmpMetrics. - Javacores during the problem: many threads waiting in
getConnection, others holding connections in slow SQL or remote calls. - Leaks: in traditional WAS, connection leak detection via the
ConnectionLeakLogictrace; in code, use try-with-resources. - Database side: long-running queries, locks, the database's own connection limit.
- Fix: correct the slow query or transaction scope, fix leaks, set a sensible connection timeout, then size the pool (max per server × servers ≤ database limit).
Key Points
- Pool exhausted: requests waited the full timeout.
- Find who holds connections: javacores and PMI.
- Leaks, slow SQL and remote calls inside transactions are common.
- Size the pool last, against the database limit.
Explanation
What interviewers look for
Using javacores and pool metrics to find the real cause.
More WebSphere questions
- Explain the traditional WebSphere Network Deployment architecture: cell, Deployment Manager, nodes, node agents, servers and clusters.
- How would you migrate an application from traditional WebSphere to Liberty?
- How does Liberty's server.xml and feature model work?
- How do you configure a JDBC data source and connection pool in Liberty and in traditional WAS?
- What is WebSphere Application Server, and how do Liberty and traditional WAS differ?
- Explain class loading in WebSphere: parent-first versus parent-last, and shared libraries.
- WSVR0605W hung thread warnings appear and the application stops responding. What do you do?
- What is JNDI, and how do applications look up resources in WebSphere?