After more investigation I think that the issue could be related to the following code:
EmbeddedCacheManager manager = new DefaultCacheManager("infinispan.xml");
Cache<String, String> cache = manager.getCache("list");
I'm using it to collect all the entries (values) of a cache and then order them.
The issue I think is that I invoke these two lines every time, and in the logs I have the following:
Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource
So for each manager instance I have a new c3p0 pool, and maybe at the end I'm going to consume all the connection to the DB (Hibernate).
So now I've created a singleton to have just one manager and one cache in memory and therefore just one pool.
I'll keep you updated on this, but if you have some thoughts or suggestions to share I'll appreciate it.