I get from time to time an exception that I cannot open a JDBC connection (my connection pool is configured to be of maximum 200 connections, and we're still in a development stage, so I really don't think that we're getting to a stage that all connections run out or something like that).
This is the exception I get:
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection
I noticed I always get it from a method that is located in a Pojo class that contains an EntityManager field (thus, I can activate the method, which is supposed to obtain some information from the database).
I pass the EntityManager object to an instance of this class, from a stateless session bean class , where the EntityManager is injected.
I do not get the exception for methods that are defined in EJBs that inject the entity manager, and unfortunately, the behavior is inconsitent (cant find a scenario that is 100% reproducable, but in all the cases it reproduced it was only at the method of this POJO).
Can anyone help and tell me if I'm doing wrong that I tried to pass the EntityManager object to a POJO and use it from its context?
In the end it had nothing to do with the EntityManager usage from POJO - our transaction timeout was too short.