We didn't succeed looking up the Sun ONE 7 transaction manager with the SunONETransactionManagerLookup class provided with hibernate 2.1.2.
However, here is an alternative solution we found. It was tested successfully in some simple examples using Oracle 9.x.
Code:
import java.util.Properties;
import javax.transaction.TransactionManager;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.transaction.TransactionManagerLookup;
public class SunOneTransactionManagerLookup implements TransactionManagerLookup
{
/**
* @see net.sf.hibernate.transaction.TransactionManagerLookup#getUserTransactionName()
*/
public String getUserTransactionName()
{
return "UserTransaction";
}
/**
* @see
* net.sf.hibernate.transaction.TransactionManagerLookup#
* getTransactionManager(java.util.Properties)
*/
public TransactionManager getTransactionManager(Properties props)
throws HibernateException
{
try
{
Class clazz = Class.forName("com.sun.jts.jta.TransactionManagerImpl");
return
(TransactionManager)
clazz.getMethod("getTransactionManagerImpl", null)
.invoke(null, null);
}
catch (Exception e)
{
throw new HibernateException(
"Could not obtain Sun ONE transaction manager instance",
e );
}
}
}
We used the following runtime parameters for Sun ONE 7:
Code:
-Dhibernate.jndi.url=iiop://<server-ip>:3700
-Dhibernate.jndi.class=com.sun.appserv.naming.S1ASCtxFactory
Dirk Fuhrmann,
Roger Wegner
http://www.ip-value.de