Announcement Announcement Module
Collapse
No announcement yet.
Configuring Spring to use EJB CMT Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configuring Spring to use EJB CMT

    I am using jboss 3.2.4, spring 1.2RC1 and Hibernate 2.1.8. I have a Session bean which calls the DAO. I want to use the EJB CMT to control my transaction. The DAO makes the call to methods in HibernateTemplate

    The spring config is loaded in the JBOSS Startup service[mbean defined in user_service.xml].

    Any help is appreciated

    Exception Trace
    ===========

    Code:
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
    ng bean with name 'transactionManager' defined in class path resource [config/sp
    ring/applicationContext.xml]: Initialization of bean failed; nested exception is
     org.springframework.transaction.TransactionSystemException: JTA UserTransaction
     is not available at JNDI location [java:comp/UserTransaction]; nested exception
     is javax.naming.NameNotFoundException: UserTransaction not bound
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFactory.java:362)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFactory.java:257)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
    (AbstractBeanFactory.java:222)

    JBOSS user_service.xml
    ===============

    Code:
    <server>
    
     <classpath codebase="." archives="xstartup.jar"/>
      
      
       <mbean code="com.icm.startup.XStartup" 
              name="user&#58;service=XStartup">
              <depends>jboss&#58;service=TransactionManager</depends>
              <depends>jboss&#58;service=ClientUserTransaction</depends>
      </mbean>
       
    </server>
    My spring config file
    =============
    Code:
    <beans>
    
    	<!-- Datasource that works in any application server -->
    	 
    	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    	        <property name="jndiName"><value>java&#58;/xactly-dataSource-oraclePool</value></property>
    	</bean>
    
    
    	<!-- Hibernate SessionFactory -->
    	
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		
    		<property name="dataSource"><ref local="dataSource"/></property>
    		
    		<!-- Must references all OR mapping files. -->
    		
    		<property name="mappingResources">
    
    			<list>	           
    
    		           <value>com/icm/entity/Business.hbm.xml</value>
    		           		           
      
    			</list>
    		
    		</property>
    		
    		<!-- Set the type of database; changing this one property will port this to Oracle, 
    			 MS SQL etc. -->
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
    			        <prop key="show_sql">true</prop>
    			</props>
    		</property>
    	</bean>
    	
        <!-- Pass the session factory to our DAO -->
    
           <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> 
           <property name="transactionManagerName"> 
                 <value>java&#58;/TransactionManager</value> 
           </property> 
    
        </bean> 
     
         
        <bean id="OrgDAOTarget" class="com.icm.org.dao.OrgDAOImplEx">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
        </bean>
    	
    
     
        <bean id="OrgDAO"
          class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref local="transactionManager"/></property>
    		<property name="target"><ref local="OrgDAOTarget"/></property>
    		<property name="transactionAttributes">
    			<props>
    			</props>
    		</property>
        </bean>
    
        <bean id="OrgDAOImplEx"
          class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref local="transactionManager"/></property>
    		<property name="target"><ref local="OrgDAOTarget"/></property>
    		<property name="proxyTargetClass"><value>true</value></property>
    		<property name="transactionAttributes">
    			<props>
    			</props>
    		</property>
        </bean>
    
    	
    </beans>

  • #2
    I believe you are missing
    <property name="userTransactionName"><value>UserTransaction</value></property>

    in your JtaTM definition.

    This is specific for JBoss (not the same as default set in JtaTM).

    "When a UserTransaction object is obtained by looking up JNDI name "UserTransaction" in the same virtual machine as JBoss, a simple interface to the JTA TransactionManager is returned. This is suitable for web components running in web containers embedded in JBoss. When components are deployed in an embedded web server, the deployer will make a JNDI link from the standard "java:comp/UserTransaction" ENC name to the global "UserTransaction" binding so that the web components can lookup the UserTranaction instance under JNDI name as specified by the J2EE."

    Rgds, Ales

    Comment


    • #3
      It worked ! Thanks

      Thanks for your suggestion

      Comment


      • #4
        Did it work?

        Comment


        • #5
          Yes it did

          Yes it did, Thanks

          Comment

          Working...
          X