After migrating from jboss4 to jboss7 (currently jboss-as-7.1.1Final), we started seeing the error 'Unable to get managed connection' during certain high load periods using the same size pool that we were using in jboss4. I put more details in this discussion: https://community.jboss.org/thread/214179
It seemed that there should still have been available connections while we got this error because MySQL showed the connections as sleeping. I was looking at the code where the error is being thrown org.jboss.jca.core.connectionmanager.AbstractConnectionManager (ironjacamar-core-impl-1.0.9.Final.jar) at line 329. I added one call that seems to help a little with our application, but I'm unsure if the benefits outweigh any negative side effects.
After line 333, failure = e; I added a pool flush. Here is the diff:
334a335,336
> pool.flush(true);
>
The flush seems to release the connection that wasn't sleeping so it can be used again.
Is there a better way to accomplish this?