-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate + Spring + WebSphere + JTA config help
PostPosted: Fri Jun 25, 2004 2:10 pm 
Newbie

Joined: Mon Apr 05, 2004 9:43 am
Posts: 4
Hello,

I'm trying to configure the subject line to use two different connections to an Oracle DB and use JTA to manage the transactions across both. I have been pouring over the documentation and have yet to find an example of such a setup.

The current issue is I'm getting the following exception when I try to retrieve info from a DB table.

Code:
[6/25/04 9:36:22:702 CDT] 37e0c3d3 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter  TRAS0014I: The following exception was logged com.ibm.ejs.cm.exception.WorkRolledbackException: Outstanding work on this connection which was not comitted or rolledback by the user has been rolledback.


I read through the Spring JtaTransaction java doc many times as well as the hibernate docs and have hit a brick wall. Here is my spring configuration

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<!--
  [ snipped out the comments to save space ]
  -->

<beans>

  <bean id="CodeDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>jdbc/codeds</value>
    </property>
  </bean>

  <bean id="ControlDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>jdbc/controlds</value>
    </property>
  </bean>

  <bean id="ControlSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <property name="dataSource"><ref local="ControlDataSource"/></property>
    <property name="mappingResources">
      <list>
        <value>springtest/Control.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.statement_cache.size">0</prop>
        <prop key="hibernate.transaction.manager_lookup_class">net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</prop>
      </props>
    </property>
  </bean>

  <bean id="CodeSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <property name="dataSource"><ref local="CodeDataSource"/></property>
    <property name="mappingResources">
      <list>
        <value>springtest/Code.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.statement_cache.size">0</prop>
        <prop key="hibernate.transaction.manager_lookup_class">net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</prop>
      </props>
    </property>
  </bean>

  <!-- WebSphere Transaction Manager Factory for spring to use to find the JTA transaction
       in WebSphere -->
  <bean id="WSTransactionFactory" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean"/>
 
  <bean id="JTATransactionManager"
        class="org.springframework.transaction.jta.JtaTransactionManager">
     <property name="transactionManager"><ref local="WSTransactionFactory"/></property>
     
  </bean>

  <bean id="CodeDataAccessObject" class="springtest.CodeDAO">
    <property name="sessionFactory"><ref local="CodeSessionFactory"/></property>
  </bean>

  <bean id="ControlDataAccessObject" class="springtest.ControlDAO">
    <property name="sessionFactory"><ref local="ControlSessionFactory"/></property>
  </bean>

  <bean id="ControlBusinessObjectTarget" class="springtest.ControlBusinessObjectImpl">
    <property name="codeDataAccessObject"><ref local="CodeDataAccessObject"/></property>
    <property name="controlDataAccessObject"><ref local="ControlDataAccessObject"/></property>
  </bean>

  <bean id="ControlBusinessObject" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager">
       <ref bean="JTATransactionManager"/>
    </property>
   
    <property name="target">
       <ref bean="ControlBusinessObjectTarget"/>
    </property>
   
    <property name="transactionAttributes">
       <props>
          <prop key="add*">PROPAGATION_REQUIRED</prop>
          <prop key="getControl*">PROPAGATION_SUPPORTS</prop>
       </props>
    </property>
  </bean>

</beans>


Here is the code for my ControlDAO

Code:
package springtest;

import net.sf.hibernate.*;
import java.util.*;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate.HibernateTemplate;
import org.springframework.orm.hibernate.SessionFactoryUtils;

public class ControlDAO extends AbstractDAO {

   public Control addControl(Control person) throws DataAccessException {
      Session session = SessionFactoryUtils.getSession(getSessionFactory(),
            true);

      try {
         session.save(person);
         session.flush();
      } catch (HibernateException e) {
         throw SessionFactoryUtils.convertHibernateAccessException(e);
      } finally {
         SessionFactoryUtils.closeSessionIfNecessary(session,getSessionFactory());
      }
      return person;
   }
   
   public List findAllControls() throws DataAccessException {
      List controls = null;
         controls = getHibernateTemplate().find("from Control as control");
      System.out.println("Returning list");
      return controls;
   }
}


When I start the server, I get the following output

Code:
[6/25/04 9:34:45:257 CDT] 5fdf03c3 ManagerAdmin  I TRAS0017I: The startup trace state is *=all=disabled.
[6/25/04 9:34:46:196 CDT] 5fdf03c3 AdminInitiali A ADMN0015I: AdminService initialized
[6/25/04 9:34:47:778 CDT] 5fdf03c3 Configuration A SECJ0215I: Successfully set JAAS login provider configuration class to com.ibm.ws.security.auth.login.Configuration.
[6/25/04 9:34:47:841 CDT] 5fdf03c3 SecurityDM    I SECJ0231I: The Security component's FFDC Diagnostic Module com.ibm.ws.security.core.SecurityDM registered successfully: true.
[6/25/04 9:34:48:499 CDT] 5fdf03c3 SecurityCompo I SECJ0309I: Java 2 Security is disabled.
[6/25/04 9:34:48:562 CDT] 5fdf03c3 SecurityCompo I SECJ0212I: WCCM JAAS configuration information successfully pushed to login provider class.
[6/25/04 9:34:48:656 CDT] 5fdf03c3 SecurityCompo I SECJ0240I: Security service initialization completed successfully
[6/25/04 9:34:48:671 CDT] 5fdf03c3 JMSRegistrati A MSGS0602I: WebSphere Embedded Messaging Client only has been installed
[6/25/04 9:34:52:008 CDT] 5fdf03c3 JMXSoapAdapte A ADMC0013I: SOAP connector available at port 8880
[6/25/04 9:34:52:023 CDT] 5fdf03c3 SecurityCompo I SECJ0243I: Security service started successfully
[6/25/04 9:34:52:023 CDT] 5fdf03c3 SecurityCompo I SECJ0210I: Security enabled false
[6/25/04 9:34:53:136 CDT] 5fdf03c3 ResourceMgrIm I WSVR0049I: Binding CodeDS as jdbc/codeds
[6/25/04 9:34:53:198 CDT] 5fdf03c3 ResourceMgrIm I WSVR0049I: Binding ControlDS as jdbc/controlds
[6/25/04 9:34:54:498 CDT] 5fdf03c3 CacheServiceI I DYNA0048I: WebSphere Dynamic Cache initialized successfully.
[6/25/04 9:34:54:890 CDT] 5fdf03c3 FileBeanStore W CNTR0023W: Directory "C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/temp" does not exist. The EJB Container will use the current directory for passivating beans.
[6/25/04 9:34:57:584 CDT] 5fdf03c3 ApplicationMg A WSVR0200I: Starting application: IBMUTC
[6/25/04 9:34:58:179 CDT] 5fdf03c3 WebContainer  A SRVE0161I: IBM WebSphere Application Server - Web Container.  Copyright IBM Corp. 1998-2002
[6/25/04 9:34:58:211 CDT] 5fdf03c3 WebContainer  A SRVE0162I: Servlet Specification Level: 2.3
[6/25/04 9:34:58:211 CDT] 5fdf03c3 WebContainer  A SRVE0163I: Supported JSP Specification Level: 1.2
[6/25/04 9:34:58:336 CDT] 5fdf03c3 WebContainer  A SRVE0169I: Loading Web Module: IBM Universal Test Client.
[6/25/04 9:34:58:618 CDT] 5fdf03c3 WebGroup      I SRVE0180I: [IBM Universal Test Client] [/UTC] [Servlet.LOG]: JSP 1.2 Processor: init
[6/25/04 9:34:58:822 CDT] 5fdf03c3 WebGroup      I SRVE0180I: [IBM Universal Test Client] [/UTC] [Servlet.LOG]: SimpleFileServlet: init
[6/25/04 9:34:59:104 CDT] 5fdf03c3 ApplicationMg A WSVR0221I: Application started: IBMUTC
[6/25/04 9:34:59:104 CDT] 5fdf03c3 ApplicationMg A WSVR0200I: Starting application: SpringTestEar
[6/25/04 9:34:59:386 CDT] 5fdf03c3 WebContainer  A SRVE0169I: Loading Web Module: SpringTest.war.
[6/25/04 9:34:59:417 CDT] 5fdf03c3 WebGroup      I SRVE0180I: [SpringTest.war] [/SpringTest] [Servlet.LOG]: JSP 1.2 Processor: init
[6/25/04 9:35:01:359 CDT] 5fdf03c3 WebGroup      I SRVE0180I: [SpringTest.war] [/SpringTest] [Servlet.LOG]: SimpleFileServlet: init
[6/25/04 9:35:01:375 CDT] 5fdf03c3 WebGroup      I SRVE0180I: [SpringTest.war] [/SpringTest] [Servlet.LOG]: InvokerServlet: init
[6/25/04 9:35:01:641 CDT] 5fdf03c3 WebGroup      I SRVE0180I: [SpringTest.war] [/SpringTest] [Servlet.LOG]: SpringContextLoader: init
[6/25/04 9:35:01:892 CDT] 5fdf03c3 WebGroup      I SRVE0180I: [SpringTest.war] [/SpringTest] [Servlet.LOG]: Loading root WebApplicationContext
[6/25/04 9:35:02:111 CDT] 5fdf03c3 XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefinitionReader  Loading XML bean definitions from resource [/WEB-INF/applicationContext.xml] of ServletContext
[6/25/04 9:35:02:503 CDT] 5fdf03c3 XmlWebApplica I org.springframework.web.context.support.XmlWebApplicationContext  Bean factory for application context [Root XmlWebApplicationContext]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [CodeDataSource,ControlDataSource,ControlSessionFactory,CodeSessionFactory,WSTransactionFactory,JTATransactionManager,CodeDataAccessObject,ControlDataAccessObject,ControlBusinessObjectTarget,ControlBusinessObject]; Root of BeanFactory hierarchy
[6/25/04 9:35:02:518 CDT] 5fdf03c3 XmlWebApplica I org.springframework.web.context.support.XmlWebApplicationContext  10 beans defined in ApplicationContext [Root XmlWebApplicationContext]
[6/25/04 9:35:02:550 CDT] 5fdf03c3 XmlWebApplica I org.springframework.web.context.support.XmlWebApplicationContext  No MessageSource found for context [Root XmlWebApplicationContext]: using empty StaticMessageSource
[6/25/04 9:35:02:581 CDT] 5fdf03c3 UiApplication I org.springframework.ui.context.support.UiApplicationContextUtils  No ThemeSource found for [Root XmlWebApplicationContext]: using ResourceBundleThemeSource
[6/25/04 9:35:02:597 CDT] 5fdf03c3 XmlWebApplica I org.springframework.web.context.support.XmlWebApplicationContext  Refreshing listeners
[6/25/04 9:35:02:597 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [CodeDataSource,ControlDataSource,ControlSessionFactory,CodeSessionFactory,WSTransactionFactory,JTATransactionManager,CodeDataAccessObject,ControlDataAccessObject,ControlBusinessObjectTarget,ControlBusinessObject]; Root of BeanFactory hierarchy]
[6/25/04 9:35:02:597 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'CodeDataSource'
[6/25/04 9:35:02:894 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'ControlDataSource'
[6/25/04 9:35:02:926 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'ControlSessionFactory'
[6/25/04 9:35:03:161 CDT] 5fdf03c3 Environment   I net.sf.hibernate.cfg.Environment  Hibernate 2.1.4
[6/25/04 9:35:03:161 CDT] 5fdf03c3 Environment   I net.sf.hibernate.cfg.Environment  hibernate.properties not found
[6/25/04 9:35:03:161 CDT] 5fdf03c3 Environment   I net.sf.hibernate.cfg.Environment  using CGLIB reflection optimizer
[6/25/04 9:35:03:176 CDT] 5fdf03c3 Environment   I net.sf.hibernate.cfg.Environment  JVM does not support Statement.getGeneratedKeys()
[6/25/04 9:35:03:192 CDT] 5fdf03c3 Environment   I net.sf.hibernate.cfg.Environment  JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled
[6/25/04 9:35:03:192 CDT] 5fdf03c3 Environment   I net.sf.hibernate.cfg.Environment  using workaround for JVM bug in java.sql.Timestamp
[6/25/04 9:35:03:740 CDT] 5fdf03c3 Binder        I net.sf.hibernate.cfg.Binder  Mapping class: springtest.Control -> AUTOVIH.CONTROLTABLE
[6/25/04 9:35:04:053 CDT] 5fdf03c3 LocalSessionF I org.springframework.orm.hibernate.LocalSessionFactoryBean  Building new Hibernate SessionFactory
[6/25/04 9:35:04:053 CDT] 5fdf03c3 Configuration I net.sf.hibernate.cfg.Configuration  processing one-to-many association mappings
[6/25/04 9:35:04:053 CDT] 5fdf03c3 Configuration I net.sf.hibernate.cfg.Configuration  processing one-to-one association property references
[6/25/04 9:35:04:053 CDT] 5fdf03c3 Configuration I net.sf.hibernate.cfg.Configuration  processing foreign key constraints
[6/25/04 9:35:04:147 CDT] 5fdf03c3 Dialect       I net.sf.hibernate.dialect.Dialect  Using dialect: net.sf.hibernate.dialect.OracleDialect
[6/25/04 9:35:04:147 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Use outer join fetching: true
[6/25/04 9:35:04:179 CDT] 5fdf03c3 ConnectionPro I net.sf.hibernate.connection.ConnectionProviderFactory  Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceConnectionProvider
[6/25/04 9:35:04:194 CDT] 5fdf03c3 TransactionMa I net.sf.hibernate.transaction.TransactionManagerLookupFactory  instantiating TransactionManagerLookup: net.sf.hibernate.transaction.WebSphereTransactionManagerLookup
[6/25/04 9:35:04:210 CDT] 5fdf03c3 TransactionMa I net.sf.hibernate.transaction.TransactionManagerLookupFactory  instantiated TransactionManagerLookup
[6/25/04 9:35:05:541 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Use scrollable result sets: true
[6/25/04 9:35:05:541 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Use JDBC3 getGeneratedKeys(): false
[6/25/04 9:35:05:541 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Optimize cache for minimal puts: false
[6/25/04 9:35:05:541 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  echoing all SQL to stdout
[6/25/04 9:35:05:541 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Query language substitutions: {}
[6/25/04 9:35:05:541 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  cache provider: net.sf.ehcache.hibernate.Provider
[6/25/04 9:35:05:682 CDT] 5fdf03c3 Configuration I net.sf.hibernate.cfg.Configuration  instantiating and configuring caches
[6/25/04 9:35:06:074 CDT] 5fdf03c3 SessionFactor I net.sf.hibernate.impl.SessionFactoryImpl  building session factory
[6/25/04 9:35:07:672 CDT] 5fdf03c3 SessionFactor I net.sf.hibernate.impl.SessionFactoryObjectFactory  no JNDI name configured
[6/25/04 9:35:07:672 CDT] 5fdf03c3 WebSphereTran I net.sf.hibernate.transaction.WebSphereTransactionManagerLookup  WebSphere 5.0
[6/25/04 9:35:07:672 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'CodeSessionFactory'
[6/25/04 9:35:07:797 CDT] 5fdf03c3 Binder        I net.sf.hibernate.cfg.Binder  Mapping class: springtest.Code -> AUTOVIH.CODETABLE
[6/25/04 9:35:07:797 CDT] 5fdf03c3 LocalSessionF I org.springframework.orm.hibernate.LocalSessionFactoryBean  Building new Hibernate SessionFactory
[6/25/04 9:35:07:797 CDT] 5fdf03c3 Configuration I net.sf.hibernate.cfg.Configuration  processing one-to-many association mappings
[6/25/04 9:35:07:797 CDT] 5fdf03c3 Configuration I net.sf.hibernate.cfg.Configuration  processing one-to-one association property references
[6/25/04 9:35:07:797 CDT] 5fdf03c3 Configuration I net.sf.hibernate.cfg.Configuration  processing foreign key constraints
[6/25/04 9:35:07:797 CDT] 5fdf03c3 Dialect       I net.sf.hibernate.dialect.Dialect  Using dialect: net.sf.hibernate.dialect.OracleDialect
[6/25/04 9:35:07:797 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Use outer join fetching: true
[6/25/04 9:35:07:797 CDT] 5fdf03c3 ConnectionPro I net.sf.hibernate.connection.ConnectionProviderFactory  Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceConnectionProvider
[6/25/04 9:35:07:797 CDT] 5fdf03c3 TransactionMa I net.sf.hibernate.transaction.TransactionManagerLookupFactory  instantiating TransactionManagerLookup: net.sf.hibernate.transaction.WebSphereTransactionManagerLookup
[6/25/04 9:35:07:797 CDT] 5fdf03c3 TransactionMa I net.sf.hibernate.transaction.TransactionManagerLookupFactory  instantiated TransactionManagerLookup
[6/25/04 9:35:07:969 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Use scrollable result sets: true
[6/25/04 9:35:07:969 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Use JDBC3 getGeneratedKeys(): false
[6/25/04 9:35:07:969 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Optimize cache for minimal puts: false
[6/25/04 9:35:07:969 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  echoing all SQL to stdout
[6/25/04 9:35:07:969 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  Query language substitutions: {}
[6/25/04 9:35:08:032 CDT] 5fdf03c3 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory  cache provider: net.sf.ehcache.hibernate.Provider
[6/25/04 9:35:08:032 CDT] 5fdf03c3 Configuration I net.sf.hibernate.cfg.Configuration  instantiating and configuring caches
[6/25/04 9:35:08:032 CDT] 5fdf03c3 SessionFactor I net.sf.hibernate.impl.SessionFactoryImpl  building session factory
[6/25/04 9:35:08:095 CDT] 5fdf03c3 SessionFactor I net.sf.hibernate.impl.SessionFactoryObjectFactory  no JNDI name configured
[6/25/04 9:35:08:095 CDT] 5fdf03c3 WebSphereTran I net.sf.hibernate.transaction.WebSphereTransactionManagerLookup  WebSphere 5.0
[6/25/04 9:35:08:095 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'WSTransactionFactory'
[6/25/04 9:35:08:095 CDT] 5fdf03c3 WebSphereTran I org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean  Found WebSphere 5.0: com.ibm.ejs.jts.jta.TransactionManagerFactory
[6/25/04 9:35:08:110 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'JTATransactionManager'
[6/25/04 9:35:08:157 CDT] 5fdf03c3 JtaTransactio I org.springframework.transaction.jta.JtaTransactionManager  Using JTA UserTransaction [com.ibm.ejs.jts.jta.UserTransactionImpl@4a6903c8] from JNDI location [java:comp/UserTransaction]
[6/25/04 9:35:08:157 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'CodeDataAccessObject'
[6/25/04 9:35:08:298 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'ControlDataAccessObject'
[6/25/04 9:35:08:361 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'ControlBusinessObjectTarget'
[6/25/04 9:35:08:392 CDT] 5fdf03c3 DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory  Creating shared instance of singleton bean 'ControlBusinessObject'
[6/25/04 9:35:08:862 CDT] 5fdf03c3 ContextLoader I org.springframework.web.context.ContextLoader  Using context class [org.springframework.web.context.support.XmlWebApplicationContext] for root WebApplicationContext
[6/25/04 9:35:08:878 CDT] 5fdf03c3 ContextLoader I org.springframework.web.context.ContextLoader  Published root WebApplicationContext [org.springframework.web.context.support.XmlWebApplicationContext: displayName=[Root XmlWebApplicationContext]; startup date=[Fri Jun 25 09:35:01 CDT 2004]; root of ApplicationContext hierarchy; config locations=[/WEB-INF/applicationContext.xml]; ] as ServletContext attribute with name [interface org.springframework.web.context.WebApplicationContext.ROOT]
.... [ snipped out all the struts stuff ] ....
[6/25/04 9:35:13:624 CDT] 5fdf03c3 WsServer      A WSVR0001I: Server server1 open for e-business


I'm stuck. I've tried all kinds of different things in the configuration file. I've also tried different ways of getting the session (getHibernateTemplate and SessionFactoryUtils). What am I missing?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 11:42 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
Could it be that your WebSphere DataSources that you fetch from JNDI are not transactional, i.e. not aware of JTA transactions? Else, WebSphere shouldn't complain that the user hasn't committed some work.

BTW, I noticed that your configuration can be slightly optimized by leveraging LocalSessionFactoryBean "jtaTransactionManager" property rather than a Hibernate TransactionManagerLookup property. This way, you can reuse a single WSTransactionFactory bean definition rather than duplicating the same configuration information.

Code:
  <bean id="ControlSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <property name="dataSource"><ref local="ControlDataSource"/></property>
    <property name="jtaTransactionManager"><ref local="WSTransactionFactory"/></property>
    <property name="mappingResources">
      <list>
        <value>springtest/Control.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.statement_cache.size">0</prop>
      </props>
    </property>
  </bean>

  <bean id="CodeSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <property name="dataSource"><ref local="CodeDataSource"/></property>
    <property name="jtaTransactionManager"><ref local="WSTransactionFactory"/></property>
    <property name="mappingResources">
      <list>
        <value>springtest/Code.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.statement_cache.size">0</prop>
      </props>
    </property>
  </bean>


Note that Spring's JtaTransactionManager just has to be aware of WebSphere's JTA TransactionManager when using transaction suspension (e.g. "PROPAGATION_REQUIRES_NEW"). Else, the default JTA UserTransaction to be found at "java:comp/UserTransaction" is good enough (JtaTransactionManager retrieves that one by default).

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 11:46 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
Could it be that your WebSphere DataSources that you fetch from JNDI are not transactional, i.e. not aware of JTA transactions? Else, WebSphere shouldn't complain that the user hasn't committed some work.

BTW, I noticed that your configuration can be slightly optimized by leveraging LocalSessionFactoryBean "jtaTransactionManager" property rather than a Hibernate TransactionManagerLookup property. This way, you can reuse a single WSTransactionFactory bean definition rather than duplicating the same configuration information.

Code:
  <bean id="ControlSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <property name="dataSource"><ref local="ControlDataSource"/></property>
    <property name="jtaTransactionManager"><ref local="WSTransactionFactory"/></property>
    <property name="mappingResources">
      <list>
        <value>springtest/Control.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.statement_cache.size">0</prop>
      </props>
    </property>
  </bean>

  <bean id="CodeSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <property name="dataSource"><ref local="CodeDataSource"/></property>
    <property name="jtaTransactionManager"><ref local="WSTransactionFactory"/></property>
    <property name="mappingResources">
      <list>
        <value>springtest/Code.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.statement_cache.size">0</prop>
      </props>
    </property>
  </bean>


Note that Spring's JtaTransactionManager just has to be aware of WebSphere's JTA TransactionManager when using transaction suspension (e.g. "PROPAGATION_REQUIRES_NEW"). Else, the default JTA UserTransaction to be found at "java:comp/UserTransaction" is good enough (JtaTransactionManager retrieves that one by default).

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 01, 2004 4:36 pm 
Newbie

Joined: Mon Apr 05, 2004 9:43 am
Posts: 4
Moved the discussion to the Spring forum. Go here for more info:

http://sourceforge.net/forum/forum.php?thread_id=1101348&forum_id=250340


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.