I have some unit tests that speak with Oracle-11g XE. Running each test individually works fine, but when I run them all, the first few pass, and the rest do not work with this error when trying to create a database connection:
ORA-12516, TNS:listener could not find available handler with matching protocol stack
This happens regardless of the order in which I run the tests, so the problem is that I'm using some kind of resource on the database server.
I tried to run the tests slowly and checked the number of connections used during the run with:
select count(*) from v$session;
The number of sessions always ranges between 26 and 28, and the limit is set to 49, so I'm not sure what the problem is.
The problem also gets worse if I run tests quickly. When I run them without any additional delays, 90% failure of this error. I slept in tearDown () to better understand what was going on, in which case only about 10% would work.
source
share