Announcement Announcement Module
Collapse
No announcement yet.
CMT and Hibernate transactions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CMT and Hibernate transactions

    Hi all,
    I'm trying to get CMT transactions (via JTA) and Hibernate to work together in my spring session. I want Hibernate to bind a single Session to the the current Thread's transaction. I receive the following error.

    Code:
    Caused by: org.springframework.transaction.TransactionSystemException: JTA TransactionManager is not available at JNDI location [java:/TransactionManager]; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object of type [class org.jboss.tm.TxManager] available at JNDI location [java:/TransactionManager] is not assignable to [javax.transaction.TransactionManager]
    	at org.springframework.transaction.jta.JtaTransactionManager.lookupTransactionManager(JtaTransactionManager.java:519)
    	at org.springframework.transaction.jta.JtaTransactionManager.initUserTransactionAndTransactionManager(JtaTransactionManager.java:428)
    	at org.springframework.transaction.jta.JtaTransactionManager.afterPropertiesSet(JtaTransactionManager.java:407)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
    	... 74 more
    Caused by: org.springframework.jndi.TypeMismatchNamingException: Object of type [class org.jboss.tm.TxManager] available at JNDI location [java:/TransactionManager] is not assignable to [javax.transaction.TransactionManager]
    	at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:148)
    	at org.springframework.transaction.jta.JtaTransactionManager.lookupTransactionManager(JtaTransactionManager.java:516)
    	... 78 more
    10:09:11,051 ERROR [JMSContainerInvoker] Exception in JMSCI message listener
    javax.ejb.TransactionRolledbackLocalException: Could not instantiate bean
    	at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:262)
    	at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
    	at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
    	at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:109)
    	at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
    	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)
    	at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:402)
    	at org.jboss.ejb.Container.invoke(Container.java:954)
    	at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:987)
    	at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1287)
    	at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:266)
    	at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:905)
    	at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)
    	at org.jboss.mq.SpySession.run(SpySession.java:323)
    	at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:194)
    	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
    	at java.lang.Thread.run(Thread.java:595)
    As you can see, Spring is erroring when it tries to bind to the transaction manager at java:/TransactionManager. However when I view the JNDI view, the implementation is org.jboss.tm.TxManager, which implements javax.transaction.TransactionManager. If I use the following, Spring initializes, but then Hibernate fails at runtime. It seems that Spring doesn't recognize the JTA Transaction manager in Jboss, but why? It implements the correct interface. I have also included by current context file

    This doesn't work for the transaction manager either
    Code:
    <jee:jndi-lookup id="jbossTxManager"
    		jndi-name="java:/TransactionManager"
    	proxy-interface="javax.transaction.TransactionManager">
    	</jee:jndi-lookup>
    My current context
    Code:
    <!--  import the default beans -->
    	<import resource="classpath:statements-processor.xml" />
    <!--TODO Todd Nine, do we need to add the JTA transactionmanager to the definition?-->
    	<bean id="hibernateSessionFactory"
    		parent="abstractHibernateSessionFactory">
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.connection.autocommit">false</prop>
    				<prop key="hibernate.connection.release_mode">
    					after_transaction
    				</prop>
    			</props>
    		</property>
    		<property name="jtaTransactionManager">
    			<ref local="transactionManager" />
    		</property>
    
    	</bean>
    
    	<bean id="transactionManager"
    		class="org.springframework.transaction.jta.JtaTransactionManager">
    		<property name="transactionManagerName">
    			<value>java:/TransactionManager</value>
    		</property>
    	</bean>
    
    	<jee:jndi-lookup id="statementsDataSource"
    		jndi-name="java:jdbc/StatementsDs"
    		proxy-interface="javax.sql.DataSource">
    	</jee:jndi-lookup>

  • #2
    Bump. Anyone? I forgot to post, I'm using JBoss 4.0.5

    Comment


    • #3
      To answer my own question, I found the answer on the JBoss forum here

      http://www.jboss.com/index.html?modu...wtopic&t=69587

      Apparently JTA was a transitive dependency of hibernate.

      Comment

      Working...
      X