thanks kevan, (about jpa ... too late, and too "lazy", me, not hibernate :-)
yes, i of course i modified the hibernate.transaction.manager_lookup_class, pointing to the class found on the wiki (which is not really perfect in the getMethod calls ...)
so, i can work on it, trying to set up a correct lookup class for geronimo if you confirm me the the jndi name for the UserTransaction in geronimo is the usual "java:comp/UserTransaction"

the hibernate configuration is this

spring config
========================
<!-- datasource -->
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/myappDS" resource-ref="true" />

<!-- Hibernate configuration -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
   
    <property name="hibernateProperties">
        <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <property name="location" value="classpath:com/myapp/data/hibernate.properties"/>
        </bean>
    </property>
    <property name="mappingDirectoryLocations">
        <list>
            <value>classpath:com/myapp/data/dao/hibernate</value>
        </list>
    </property>
    <property name="eventListeners">
        <map>
            <entry key="merge">
                <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
            </entry>
        </map>
    </property>
</bean>

hibernate.properties
================================
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.current_session_context_class=jta
hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class=org.hibernate.transaction.GeronimoTransactionManagerLookup
hibernate.cache.use_second_level_cache=false
hibernate.cache.use_query_cache=false
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update


as you can see, the datasource is looked up in jndi (it has been imported from jboss and it looks ok)
and configured in geronimo-web-xml together with javamail
===================
<dep:dependencies>
    <dependency>
        <groupId>console.dbpool</groupId>
        <artifactId>myappDS</artifactId>
        <version>1.0</version>
        <type>rar</type>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.configs</groupId>
        <artifactId>javamail</artifactId>
        <version>2.0.1</version>
        <type>car</type>
    </dependency>
</dep:dependencies>
....
<resource-ref>
    <ref-name>jdbc/myappDS</ref-name>
    <resource-link>myappDS</resource-link>
</resource-ref>
<resource-ref>
    <ref-name>mail/DefaultMail</ref-name>
    <resource-link>mail/MailSession</resource-link>
</resource-ref>

and this is the updated version of the GeronimoTransactionManagerLookup class (with some modifications ...)
===========================
package org.hibernate.transaction;

import java.util.Properties;
import javax.management.ObjectName;
import javax.transaction.TransactionManager;
import org.hibernate.HibernateException;
import org.hibernate.transaction.TransactionManagerLookup;

public class GeronimoTransactionManagerLookup
    implements TransactionManagerLookup
{
   public static final String TransactionMgrGBeanName="geronimo.server:J2EEApplication=null,J2EEModule=geronimo/j2ee-server/2.0.1/car,J2EEServer=geronimo,j2eeType=TransactionManager,name=TransactionManager";
   public static final String UserTransactionName = "java:comp/UserTransaction";

   public TransactionManager getTransactionManager(Properties props) throws HibernateException {
   try {
         Class kernelClass = Class.forName("org.apache.geronimo.kernel.Kernel");
         Class kernelRegistryClass = Class.forName("org.apache.geronimo.kernel.KernelRegistry");
         Class proxyManagerClass = Class.forName("org.apache.geronimo.kernel.proxy.ProxyManager");
         ObjectName TransactionManagerName = new ObjectName(TransactionMgrGBeanName);
         Object kernel = kernelRegistryClass.getMethod("getSingleKernel", new Class[] {}).invoke(null, new Object[] {});
         Object proxyManager = kernelClass.getMethod("getProxyManager",new Class[] {}).invoke(kernel,new Object[] {});
         Class[] clzArray = {ObjectName.class,Class.class};
         Object[] objArray = {TransactionManagerName, TransactionManager.class};
         return (TransactionManager)proxyManagerClass.getMethod("createProxy",clzArray).
             invoke(proxyManager, objArray);

       }catch (Exception e) {
           throw new HibernateException("Geronimo Transaction Manager Lookup Failed", e);
       }
}

   public String getUserTransactionName() {
       return UserTransactionName;
   }
}


Kevan Miller wrote:

On Aug 28, 2007, at 6:04 AM, Paolo Denti wrote:

Hi Kevan,
i was using spring 2.0.6

following your suggestions and david's,
I downloaded the tomcat version and added
<dep:hidden-classes>
 <dep:filter>org.springframework.</dep:filter>
 <dep:filter>META-INF/spring</dep:filter>
</dep:hidden-classes>
to geronimo-web.xml

but still the deploy does not work. now i stucked just a little bit forward. I saw that no org.hibernate.transaction.TransactionManagerLookup implementations exists for geronimo.
I found here (http://cwiki.apache.org/GMOxDOC10/jboss-to-geronimo-hibernate-migration.html) an implementation (GeronimoTransactionManagerLookup) that i included in the package but it looks that it does not work.

10:32:23,124 ERROR [JTATransaction] Could not find UserTransaction in JNDI
javax.naming.NameNotFoundException: UserTransaction
       at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:163)
       at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:597)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:60)
       at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:57)
       at org.hibernate.jdbc.JDBCContext.getTransaction(JDBCContext.java:193)
       at org.hibernate.impl.SessionImpl.getTransaction(SessionImpl.java:1315)
       at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1325)
...

Nice work, Paolo. One note: the <hidden-classes> should not be strictly necessary running on Tomcat, but one can never be too careful... ;-)

Looks like we need to update that example for 2.0... I'm not much of a hibernate expert. Give me a bit and will get UserTransaction lookup working for you...

FYI, there is a J2G (JBoss to Geronimo) migration tool under development in Geronimo. IIUC, it wouldn't help in this case, but I could be wrong...

BTW, did you configure the hibernate.transaction.manager_lookup_class in your hibernate configuration? 

In the meantime, ask Hibernate to add an Apache Geronimo lookup class... :-) Heh. Or better yet, start using JPA! ;-)

Back soon...

--kevan

Reply via email to