users@glassfish.java.net

Spring transaction management in glassfish

From: <glassfish_at_javadesktop.org>
Date: Mon, 21 Jan 2008 11:16:08 PST

Has anyone had success with spring declarative transaction management inside spring?

I've tried both LOCAL_RESOURCE and JTA in my persistence.xml file, and I can't get either to work. When I try to deploy a war to Glassfish, it complains that I can't use LOCAL_RESOURCE. When I try JTA, I get "Cannot deactivate transaction synchronization - not active" when my method is done.

I can't seem to get the correct combination of configuration options to make this work. I'm using the latest Glassfish and Spring 2.5. I have a WebService annotated method that gets a Spring bean that is marked with the Transactional attribute.

Relevant parts of my configuration is as follows:
web.xml:
    <persistence-unit-ref>
        <persistence-unit-ref-name>persistence/default</persistence-unit-ref-name>
        <persistence-unit-name>default</persistence-unit-name>
    </persistence-unit-ref>

persistence.xml:
    <persistence-unit name="default" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>jdbc/sane</jta-data-source>
        <class>com.pinnacol.framework.dataobject.DataObject</class>
        <class>com.pinnacol.framework.dataobject.TaskTiming</class>
        <class>com.pinnacol.framework.dataobject.WorkflowTiming</class>
        <properties>
            <property name="hibernate.cache.provider_class"
                      value="net.sf.ehcache.hibernate.EhCacheProvider"/>
            <property name="hibernate.cache.use_second_level_cache" value="true"/>
            <property name="hibernate.cache.use_query_cache" value="false"/>
        </properties>
    </persistence-unit>

Spring's applicationContext.xml:
    <context:annotation-config/>
    <jee:jndi-lookup id="entityManagerFactroy" jndi-name="java:comp/env/persistence/default"/>
    <tx:annotation-driven transaction-manager="transactionManager"/>
    <bean id="transactionManager"
          class="org.springframework.transaction.jta.JtaTransactionManager">
    </bean>

Anyone have any ideas how I can get Spring and Glassfish to play together?

Thanks for any pointers,

Steve
[Message sent by forum member 'ssaliman' (ssaliman)]

http://forums.java.net/jive/thread.jspa?messageID=255033