geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Viet Nguyen" <vhng...@gmail.com>
Subject Re: Problem at geronimo boot
Date Thu, 30 Aug 2007 02:02:58 GMT
Well I try your code Kevan, and I altered it some to get this:

package org.hibernate.transaction;

import java.util.Iterator;
import java.util.Properties;
import java.util.Set;

import javax.transaction.TransactionManager;
import org.hibernate.HibernateException;
import org.hibernate.transaction.TransactionManagerLookup;

import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.KernelRegistry;
import org.apache.geronimo.kernel.proxy.ProxyManager;

public class GeronimoTransactionManagerLookup
    implements TransactionManagerLookup {

   public static final String UserTransactionName =
"java:comp/UserTransaction";

   public TransactionManager getTransactionManager(Properties props) throws
HibernateException {
       try {
           Kernel kernel = KernelRegistry.getSingleKernel();
           ProxyManager proxyManager = kernel.getProxyManager();
           AbstractNameQuery query = new AbstractNameQuery(
TransactionManager.class.getName());
           Set names = kernel.listGBeans(query);
           AbstractName name = null;
           for (Iterator it = names.iterator(); it.hasNext();)
               name = (AbstractName) it.next();
           Object transMg = (Object) proxyManager.createProxy(name,
TransactionManager.class);
           return (TransactionManager)transMg;
       }catch (Exception e) {
           e.printStackTrace();
           System.out.println();
           throw new HibernateException("Geronimo Transaction Manager Lookup
Failed", e);
       }
}

   public String getUserTransactionName() {
       return UserTransactionName;
   }
}

I tested it out and everything works on geronimo-jetty6-jee5-2.0.1

So I hope you can test it out Paolos.

Hope this works,
Viet Nguyen

Mime
View raw message