We are using stateless EJB for this enterprise service. A servlet handles the service request (around 10 million/day) and it in turn invokes the stateless EJB. EJB calls a business delegate (POJO) to get data from database and different external systems.
EJB gets the connection from pool using data source and passes it the delegate. But we need to make database (Oracle) calls in between invoking the external systems. So we make the database call and return the connection (connection.close()) to the pool. We return the connection to the pool to avoid holding the connection till the completion of the external system call.
We are getting connection not available errors. While debugging the issue we noticed that returned connection is not available in the pool.
Is there any property in EJB or connection pool that is holding the connection by the app even though we release it?
Getting connection in EJB:
connection = JDBCConnectionFactory.instance().getConnection();