[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Using EntityManager from a POJO

yair.zaslavsky do-not-reply at jboss.com
Thu Oct 19 05:20:09 EDT 2006

Hi all,
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
	at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:567)
	at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:56)

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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979292#3979292

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979292

More information about the jboss-user mailing list