openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hans J. Prueller" <>
Subject RE: WARNING: Connection not closed by caller - messages produced byOpenJPA?
Date Wed, 28 Mar 2007 19:13:54 GMT
The usage case of the EM is, that I call a
PersistenceService.getEntityManager() method in every method of my
SLSB's, the SLSBs all have
the "Required" attribute set for TXs, so every time I call the getEM()
method, there should be an already running JTA TX. 

This is the code:

				"creating a fresh, clean EntityManager from JNDI EMF.");

		// EntityManagerFactory emf = OpenJPAPersistence
		// .createEntityManagerFactory(EMF_JNDI_LOCATION, (Context) null);

		final EntityManagerFactory emf = getEMF();

		final BrokerFactory bf = OpenJPAPersistence.toBrokerFactory(emf);

		final Broker b = bf.newBroker(bf.getConfiguration()
				.getConnectionUserName(), bf.getConfiguration()
				.getConnectionPassword(), true, // the broker is part of a JTA
managed tx
				bf.getConfiguration().getConnectionRetainModeConstant(), true); //
look for an existing Broker on the tx

		// do some JPA configuration setup. Logic stolen from
		// EntityManagerFactoryImpl.
		b.setAutoDetach(AutoDetach.DETACH_CLOSE, true);
		b.setAutoDetach(AutoDetach.DETACH_ROLLBACK, true);

		return OpenJPAPersistence.toEntityManager(b);

And here you have the persistence.xml:

<persistence-unit name="lbsims" transaction-type="JTA">
			<property name="openjpa.ConnectionFactoryMode"
				value="managed" />
			<property name="openjpa.ManagedRuntime"
				value="jndi(TransactionManagerName=java:comp/UserTransaction)" />
			<property name="openjpa.DataCache" value="true"/>
			<property name="openjpa.RemoteCommitProvider" value="sjvm"/>		


Am Mittwoch, den 28.03.2007, 11:54 -0700 schrieb Patrick Linskey:

> Also, how are you integrating it with the JTA transaction? Are you
> calling EM.joinTransaction(), or ensuring that the transaction is in
> progress before creating the EM, or something else?
> -Patrick

View raw message