Atomikos Forum

Could not find UserTransaction in JNDI [java:comp/UserTransactio

I am trying to install Atomikos transaction manager and I am getting the following error. 

org.hibernate.TransactionException: Could not find UserTransaction in JNDI [java:comp/UserTransaction]

I am using Tomcat 6.2x, Hibernate3, Spring3.0.6, ActiveMQ 5.4.2

Here is my applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans  xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:core="http://activemq.apache.org/schema/core"
        xmlns:jdbc="http://www.springframework.org/schema/jdbc"
        xmlns:jee="http://www.springframework.org/schema/jee"
        xmlns:jms="http://www.springframework.org/schema/jms"
        xmlns:lang="http://www.springframework.org/schema/lang"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:oxm="http://www.springframework.org/schema/oxm"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:security="http://www.springframework.org/schema/security"
        xmlns:task="http://www.springframework.org/schema/task"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
            http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core
            http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
            http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
            http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
            http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
            http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
 
   
    <!-- configure an Atomikos JTA-aware datasource -->   
    <bean id="dataSource"     
    class="com.atomikos.jdbc.AtomikosDataSourceBean"     
    init-method="init" destroy-method="close">       
    <!-- set an arbitrary but unique name for the datasource -->     
    <property name="uniqueResourceName">
    <value>XADBMS</value>
    </property>       
    <!--  set the underlying driver class to use,             
    in this example case we use Oracle        -->     
    <property name="xaDataSourceClassName">         
    <value>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</value>     
    </property>     
    <property name="xaProperties">         
    <!-- set the driver-specific XADataSource properties
        (check your driver docs for more info)         
    -->               
        <props>                       
        <prop key="user">user</prop>                       
        <prop key="password">password</prop>                       
        <prop key="URL">jdbc:mysql://localhost:3306/ordermanagement</prop>               
        </props>     
      </property>         
      <!-- how many connections in the pool? -->     
      <property name="poolSize" value="3"/>   
      </bean>
   
    <!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <!--  IMPORTANT: make sure to refer to an ATOMIKOS         
        JTA/XA datasource for the sessionFactory!    -->
        <property name="dataSource" ref="dataSource"></property> 
        <property name="mappingResources">       
            <list>
                <value>ActAudit.hbm.xml</value>
               
            </list>         
        </property>     
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.transaction.factory_class"> org.hibernate.transaction.JTATransactionFactory</prop>   
                <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
            </props>
        </property>
    </bean>
 
    <tx:annotation-driven />
   
   
   
    <bean id="log4jInitialization" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
          p:targetClass="org.springframework.util.Log4jConfigurer"
          p:targetMethod="initLogging"
          p:arguments="./test/properties/log4j.properties" />


   
   
   
    <bean id="messageDAO"
          class="dao.impl.MessageDAOImpl" />
         
    <bean id="orderDAO"
          class="dao.impl.OrderDAOImpl" />
         
    <bean id="routingDAO"
          class="dao.impl.RoutingDAOImpl" />

    <bean id="shopDAO"
          class="dao.impl.ShopDAOImpl" />
     
    <bean id="userDAO"
          class="dao.impl.UserDAOImpl" />
         
    <!-- Finished transactional DAOs configuration -->
    <!-- ================================================================== -->
   
   
  <!-- Construct Atomikos UserTransactionManager,             
  needed to configure Spring          -->   
  <bean id="AtomikosTransactionManager"
  class="com.atomikos.icatch.jta.UserTransactionManager"     
              init-method="init" destroy-method="close">     
  <!--  when close is called, should we force transactions to terminate or not? -->     
          <property name="forceShutdown" value="false" />   
  </bean>   
 
  <!-- Also use Atomikos UserTransactionImp,
  needed to configure Spring          -->   
  <bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">       
          <property name="transactionTimeout" value="300" />   
  </bean>   
 
  <!-- Configure the Spring framework to use JTA transactions from Atomikos -->   
  <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">     
          <property name="transactionManager" ref="AtomikosTransactionManager" />     
          <property name="userTransaction" ref="AtomikosUserTransaction" />   
  </bean>

   
   
    <bean id="xaFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">       
        <property name="brokerURL">           
            <value>tcp://localhost:61616</value>       
          </property>   
    </bean>
   
    <!-- Connection Pool -->
  <bean id="connectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean" init-method="init" destroy-method="close">
      <property name="uniqueResourceName" value="ConnectionTransaction"/>
      <property name="xaConnectionFactory" ref="xaFactory"/>
  </bean>
 
  <bean id="defaultListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
      <property name="receiveTimeout" value="10000"/>
      <property name="connectionFactory" ref="connectionFactory"/>
        <property name="messageListener" ref="tfsiOutMessageListener"/>
        <property name="destinationName" value="FSIoutbound" />
      <property name="transactionManager" ref="transactionManager"/>
      <property name="sessionTransacted" value="true"/>
      <property name="sessionAcknowledgeMode" value="0"/>
      <property name="errorHandler" ref="jmsErrorHandler"/>
  </bean>
 
 
 
    <bean id="jmsErrorHandler" class="jms.JMSErrorHandler" />
 
   
 
</beans>


I am not using JNDI, don't know why it is looking for it
jay pursoo Send private email
Tuesday, November 15, 2011
 
 
Forgot to mention using hibernate 3.6.2 and AtomiokosTransactionsEssentials-3.7.0
jay pursoo Send private email
Tuesday, November 15, 2011
 
 
Did you check here? http://www.atomikos.com/Documentation/HibernateIntegration

You might want to try switching

<prop key="hibernate.transaction.factory_class"> org.hibernate.transaction.JTATransactionFactory</prop>   

... for the atomikos equivalent in the doc page I refer to above

HTH
Guy Pardon Send private email
Wednesday, November 30, 2011
 
 
thats exactly what I did and got it working

                  <prop key="hibernate.transaction.factory_class">com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory</prop>   


Thanks Guy
jay pursoo Send private email
Wednesday, November 30, 2011
 
 
If you are using spring managed transactions (to demarcate boundaries) and atomikos to use the JTA stuff, i would prefer to use:

org.hibernate.transaction.CMTTransactionFactory

as factory class.

The custom Atomikos one should not be needed anymore with hibernate 3.6.x.
See here: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html - 3.8.1.

All you should need is the manager lookup class.

Give it a try and report any issues if you encounter them.
Torsten Krah Send private email
Thursday, December 08, 2011
 
 
made the change it is working fine, thanks
jay pursoo Send private email
Friday, December 16, 2011
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics