Hi David, Kevan
first of all, thanks. now it deploys !

It looks that the transactionManager is correctly looked up but ... at the first usage of the TM i get this error
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader

is it related with geronimo classloading issues ?

Paolo

David Jencks wrote:
I'd recommend a slight change...

           AbstractNameQuery query = new AbstractNameQuery(TransactionManager.class.getName ());
           Set<AbstractName> names = kernel.listGBeans(query);
           if (names.size() != 1) {
               throw new IllegalStateException("Expected one transaction manager, not " + names.size());
           }
           AbstractName name = names.iterator().next();
           TransactionManager transMg = (TransactionManager) kernel.getGBean(name);
           return (TransactionManager)transMg;

I don't think there's a good reason to use a proxy...

thanks
david jencks


On Aug 29, 2007, at 7:02 PM, Viet Nguyen wrote:

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


Reply via email to