tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Vysny <...@whitestein.com>
Subject Re: OpenEJB and Hibernate
Date Tue, 16 Oct 2007 14:51:24 GMT

On Mon, 2007-10-15 at 11:06 +0200, Martin Vysny wrote:
> On Fri, 2007-10-12 at 13:54 -0700, Dain Sundstrom wrote:
> > On Oct 12, 2007, at 2:41 AM, Martin Vysny wrote:
> > 
> > > Hi guys,
> > >   I tried to use Hibernate in OpenEJB (our application unfortunately
> > > still does not use JPA - it uses Hibernate directly instead). However,
> > > it seems there is a version clash: OpenEJB requires ASM 2.2.3 while
> > > Hibernate 3.2.4 requires ASM 1.5.3 and they seem to be incompatible:
> > >
> > > ...
> > >
> > > Have you guys tried to use OpenEJB with Hibernate? Can you please
> > > provide me with some hints? Which one is harder: modify Hibernate
> > > to use 2.2.3 or OpenEJB to use 1.5.3? :-)
> > 
> > I wouldn't try to modify either; I'd repackage.  Most projects seem  
> > to repackage asm to avoid such conflicts, and I'd guess they do it  
> > because Hibernate is not repackaging :)
> > 
> > The ASM FAQ suggests (http://asm.objectweb.org/doc/faq.html) jarjar.   
> > If you can figure out how to do this, that would be awesome.  We can  
> > simply add the repackaged jar to our svn repository.
> > 
> > -dain
> > 
> 
> Thanks very much for the idea, but we found an easier way to resolve
> this issue: [1]. Now can you help us where to look for
> TransactionManager in JNDI? Hibernate requires it when using CMP
> persistency. Thanks!

Okay, it's java:comp/TransactionManager from within a bean, or
java:openejb/TransactionManager from outside a bean ;) We are using
Hibernate via the JPA interface as follows:

package com.whitestein.fe.impl.config;

import org.hibernate.transaction.JNDITransactionManagerLookup;

/**
 * Hibernate Transaction manager lookup strategy for OpenEJB.
 * 
 * @author mvy
 */
public class OpenEJBTransactionManagerLookup extends
		JNDITransactionManagerLookup {

	@Override
	protected String getName() {
		return "java:comp/TransactionManager"; //$NON-NLS-1$
	}

	public String getUserTransactionName() {
		return "java:comp/UserTransaction"; //$NON-NLS-1$
	}

}


properties.put(Environment.DIALECT, dbDialect);
properties.put(Environment.TRANSACTION_MANAGER_STRATEGY,
OpenEJBTransactionManagerLookup.class.getName());
properties.put(Environment.TRANSACTION_STRATEGY,
CMTTransactionFactory.class.getName());
properties.put(Environment.JNDI_CLASS,
"org.apache.openejb.client.LocalInitialContextFactory");
entityManagerFactory = Persistence.createEntityManagerFactory(
persistenceUnitName, properties);

This way, Hibernate joins the container transactions.

Martin Vysny


Mime
View raw message