geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@21technologies.com
Subject Re: Geronimo 1.1 with Hibernate 3.1
Date Fri, 05 Jan 2007 18:18:58 GMT
Peter,
   did you end up trying this? Did it work for you? I will need to use 
something similar very soon.

-- 
Jimmy Wan
Senior Technical Lead
21st Century Technologies, Inc.
URL: http://www.21technologies.com
The information in this email and in any attachments is confidential and 
may be privileged. If you are not the intended recipient, please destroy 
this message, delete any copies held on your systems and notify the sender 
immediately. You should not retain, copy or use this email for any 
purpose, nor disclose all or any part of its content to any other person.



"Michele La Porta" <michele.laporta@gmail.com> 
11/08/2006 07:16
Please respond to
user@geronimo.apache.org


To
user@geronimo.apache.org
cc

Subject
Re: Geronimo 1.1 with Hibernate 3.1






You can try this:


package org.hibernate.transaction;

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

import javax.transaction.TransactionManager;

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;
import org.apache.geronimo.transaction.context.TransactionContextManager;
import org.hibernate.HibernateException;

public class GeronimoTransactionManagerLookup implements
        TransactionManagerLookup {

    // geronimo 1.1 object name
    public static final String TransactionMgrGBeanName = 
"geronimo.server:J2EEApplication=null,J2EEModule=geronimo/j2ee-server/1.1-SNAPSHOT/car,J2EEServer=geronimo,j2eeType=TransactionContextManager,name=TransactionContextManager";


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

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

    public String getUserTransactionName() {
        return UserTransactionName; 
    }
}

Remember to set this hibernate.properties

        <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect 
">org.hibernate.dialect.SQLServerDialect</prop>
                    <prop key="hibernate.show_sql">false</prop>
                    <prop key="hibernate.cglib.use_reflection_optimizer 
">true</prop>
                    <prop 
key="hibernate.transaction.flush_before_completion">true</prop>
                    <prop key="hibernate.transaction.auto_close_session 
">true</prop>
 
                       <prop 
key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>

 
                    <prop key=" 
hibernate.transaction.manager_lookup_class">org.hibernate.transaction.GeronimoTransactionManagerLookup</prop>
                     <prop 
key="hibernate.current_session_context_class">thread</prop> 
                    <!-- <prop 
key="hibernate.current_session_context_class">jta</prop>-->
                    <prop 
key="jta.UserTransaction">java:comp/UserTransaction</prop> 
 
                    <prop 
key="hibernate.cache.use_query_cache">true</prop>
                    <prop 
key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider 
</prop>
                    <prop 
key="hibernate.cache.provider_configuration_file_resource_path">src/main/resources/ehcache-hibernate3.xml</prop>

 
                </props> 
        </property>


On 11/8/06, Peter <peter.empen@dak.de> wrote:
A suggested solution for Geronimo 1.0 is available at
http://cwiki.apache.org/confluence/display/GMOxDOC10/JBoss+to+Geronimo+-
+Hibernate+Migration. Unfortunately this does not work for Geronimo 1.1.

What I have tried is:
public class GeronimoTransactionManagerLookup
    implements TransactionManagerLookup
{
   public static final String TransactionMgrGBeanName=
                        " geronimo.server:J2EEApplication=null," +
                        "J2EEModule=geronimo/j2ee-server/1.1.1/car," +
                        "J2EEServer=geronimo,j2eeType=TransactionManager," 
+
                        "name=TransactionManager";
   ...

but I still get

DEBUG [SessionFactoryObjectFactory] initializing class
SessionFactoryObjectFactory
DEBUG [SessionFactoryObjectFactory] registered: 
8b81890a0ec727bb010ec727c8de0000 (unnamed)
INFO  [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI 
name
configured
DEBUG [SessionFactoryImpl] instantiated session factory
DEBUG [SessionFactoryImpl] obtaining JTA TransactionManager 
ERROR [PersistenceManager] Geronimo Transaction Manager Lookup Failed
org.hibernate.HibernateException: Geronimo Transaction Manager Lookup 
Failed
        at
org.hibernate.transaction.GeronimoTransactionManagerLookup.getTransactionManage 

r(GeronimoTransactionManagerLookup.java:29)
        at org.hibernate.impl.SessionFactoryImpl.<init>
(SessionFactoryImpl.java:301)
        at org.hibernate.cfg.Configuration.buildSessionFactory
(Configuration.java :1154)

How should this GBeanName be set? Or do I need to change something else?


Mime
View raw message