On Aug 4, 2008, at 5:45 AM, Marcin Kwapisz wrote:

It may be that TopLink doesn't know how to find our
TransactionManager.  OpenJPA finds it automatically by calling
org.apache.openejb.OpenEJB.getTransactionManager().  For Hibernate,
there's the TransactionManagerLookup which can be configured.  Do you
know if there's anything similar in TopLink?

[Marcin Kwapisz]
Thanks David for the hint.

There is such feature and similar problem (solution also) is described here:
http://forums.oracle.com/forums/thread.jspa?threadID=625250&tstart=0&messageID=2390496
and here:
http://www.jroller.com/guruwons/entry/use_glassfish_java_persistence_provider

The only one thing I had to find was TransactionManager jndi name: java:comp/TransactionManager

public class OpenEJBTransactionController extends JTATransactionController
{

public static final String JNDI_TRANSACTION_MANAGER_NAME = "java:comp/TransactionManager";

   public OpenEJBTransactionController()
   {
       super();
   }

   @Override
protected TransactionManager acquireTransactionManager() throws Exception
   {
return (TransactionManager) jndiLookup(JNDI_TRANSACTION_MANAGER_NAME);
   }
}

and in persistence.xml

<property name="toplink.target-server" value="pl.zsk.samples.ejbservice.OpenEJBTransactionController"/>

Fantastic, thank you!

Added some features for you and other TopLink/EclipseLink users. We now generate an implement of JTATransactionController and will automatically set the target-server property if we determine you are using the TopLink or EclipseLink providers.

http://issues.apache.org/jira/browse/OPENEJB-880
http://issues.apache.org/jira/browse/OPENEJB-881

So when 3.1 comes out, you shouldn't need to set the toplink.target- server property anymore and will be able to dump your custom OpenEJBTransactionController, though it will continue to work if you want to use it (i.e. we won't override the property if we see you've set it to a custom class).

Sort of a conceptual copy of what we did for hibernate:  
http://issues.apache.org/jira/browse/OPENEJB-801


-David


Reply via email to