Hibernate version 2.1.7
Hello all,
I have implemented parts of an application in an websphere environment (wsad 5.1.1) using spring + hibernate. I have not until now have had the need for JTA, so I have been using org.apache.commons.dbcp.BasicDataSource with a DatasourceTransactionManager. It has worked fine.
However, I have now tried to configure up an JTA environment and run into some probems. I do not know if the problem is due to Spring or Hibernate, but I'll try this forum.
At server startup, the spring applicationContext is initialized as well as the hibernate session factory. After all initialization is done, I receive the error "Resource jdbc/CPC_DS rolled back in cleanup of unresolved LocalTransactionContainment."
I cannot see any errors in the log before this, and the exception stack trace is not very informative.
During initialization, LocalDataSourceConnectionProvider is initialized. Is this normal using JTA, or could that be the cause of my problem?
Has anyone come across a similar problem previously? Any help is greatly appreciated!
Regards
Niklas
My bean configuration:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>java:comp/env/jdbc/CPC_DS.ref</value></property>
</bean>
<bean id="wsTransactionManager" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean" />
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager">
<ref local="wsTransactionManager" />
</property>
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list>
<value>hbm/generated/XXXX.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.connection.pool_size">3</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<further configuration omitted>
</beans>
the log:
Code:
[2005-01-14 15:59:20:516 CET] 3c89a97a ContextLoader I org.springframework.web.context.ContextLoader Root WebApplicationContext: initialization started
[2005-01-14 15:59:20:516 CET] 3c89a97a WebGroup I SRVE0180I: [cpcWeb] [/cpcWeb] [Servlet.LOG]: Loading Spring root WebApplicationContext
[2005-01-14 15:59:20:672 CET] 3c89a97a XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefinitionReader Loading XML bean definitions from class path resource [applicationContext.xml]
[2005-01-14 15:59:20:938 CET] 3c89a97a XmlWebApplica I org.springframework.web.context.support.XmlWebApplicationContext Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext;hashCode=23374191]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,wsTransactionManager,transactionManager,sessionFactory,cpcDao,soiDao,segmentDao,cpcItemHandler,soiHandler,segmentHandler,cpcFacade,txProxyTemplate,testFacade,testFacadeTarget,buyingAgreementFacade,buyingAgreementFacadeTarget,calculationFacade,calculationFacadeTarget,centralParamFacade,centralParamFacadeTarget,itemFacade,itemFacadeTarget,importFacade,importFacadeTarget,systemFacade,systemFacadeTarget]; root of BeanFactory hierarchy
[2005-01-14 15:59:20:969 CET] 3c89a97a XmlWebApplica I org.springframework.web.context.support.XmlWebApplicationContext 26 beans defined in application context [org.springframework.web.context.support.XmlWebApplicationContext;hashCode=23374191]
[2005-01-14 15:59:21:000 CET] 3c89a97a XmlWebApplica I org.springframework.web.context.support.XmlWebApplicationContext Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.StaticMessageSource: {}]
[2005-01-14 15:59:21:016 CET] 3c89a97a XmlWebApplica I org.springframework.web.context.support.XmlWebApplicationContext Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@18d7e966]
[2005-01-14 15:59:21:016 CET] 3c89a97a UiApplication I org.springframework.ui.context.support.UiApplicationContextUtils No ThemeSource found for [org.springframework.web.context.support.XmlWebApplicationContext;hashCode=23374191]: using ResourceBundleThemeSource
[2005-01-14 15:59:21:031 CET] 3c89a97a XmlWebApplica I org.springframework.web.context.support.XmlWebApplicationContext Refreshing listeners
[2005-01-14 15:59:21:031 CET] 3c89a97a DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,wsTransactionManager,transactionManager,sessionFactory,cpcDao,soiDao,segmentDao,cpcItemHandler,soiHandler,segmentHandler,cpcFacade,txProxyTemplate,testFacade,testFacadeTarget,buyingAgreementFacade,buyingAgreementFacadeTarget,calculationFacade,calculationFacadeTarget,centralParamFacade,centralParamFacadeTarget,itemFacade,itemFacadeTarget,importFacade,importFacadeTarget,systemFacade,systemFacadeTarget]; root of BeanFactory hierarchy]
[2005-01-14 15:59:21:031 CET] 3c89a97a DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory Creating shared instance of singleton bean 'dataSource'
[2005-01-14 15:59:21:297 CET] 3c89a97a JndiObjectFac I org.springframework.jndi.JndiObjectFactoryBean Located object with JNDI name [java:comp/env/jdbc/CPC_DS.ref]: value=[com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@4b646965]
[2005-01-14 15:59:21:312 CET] 3c89a97a DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory Creating shared instance of singleton bean 'wsTransactionManager'
[2005-01-14 15:59:21:312 CET] 3c89a97a WebSphereTran I org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean Found WebSphere 5.1: com.ibm.ws.Transaction.TransactionManagerFactory
[2005-01-14 15:59:21:312 CET] 3c89a97a DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory Creating shared instance of singleton bean 'transactionManager'
[2005-01-14 15:59:21:391 CET] 3c89a97a JtaTransactio I org.springframework.transaction.jta.JtaTransactionManager Using JTA UserTransaction [com.ibm.ws.Transaction.JTA.UserTransactionImpl@4ee0e96b] from JNDI location [java:comp/UserTransaction]
[2005-01-14 15:59:21:391 CET] 3c89a97a DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory Creating shared instance of singleton bean 'sessionFactory'
[2005-01-14 15:59:21:469 CET] 3c89a97a Environment I net.sf.hibernate.cfg.Environment Hibernate 2.1.7
[2005-01-14 15:59:21:469 CET] 3c89a97a Environment I net.sf.hibernate.cfg.Environment hibernate.properties not found
[2005-01-14 15:59:21:484 CET] 3c89a97a Environment I net.sf.hibernate.cfg.Environment using CGLIB reflection optimizer
[2005-01-14 15:59:21:484 CET] 3c89a97a Environment I net.sf.hibernate.cfg.Environment using JDK 1.4 java.sql.Timestamp handling
[2005-01-14 15:59:22:047 CET] 3c89a97a Binder I net.sf.hibernate.cfg.Binder Mapping class: ***
[2005-01-14 15:59:23:391 CET] 3c89a97a LocalSessionF I org.springframework.orm.hibernate.LocalSessionFactoryBean Building new Hibernate SessionFactory
[2005-01-14 15:59:23:391 CET] 3c89a97a Configuration I net.sf.hibernate.cfg.Configuration processing one-to-many association mappings
[2005-01-14 15:59:23:391 CET] 3c89a97a Binder I net.sf.hibernate.cfg.Binder Mapping collection: ***
[2005-01-14 15:59:23:469 CET] 3c89a97a Configuration I net.sf.hibernate.cfg.Configuration processing one-to-one association property references
[2005-01-14 15:59:23:469 CET] 3c89a97a Configuration I net.sf.hibernate.cfg.Configuration processing foreign key constraints
[2005-01-14 15:59:23:547 CET] 3c89a97a Dialect I net.sf.hibernate.dialect.Dialect Using dialect: net.sf.hibernate.dialect.OracleDialect
[2005-01-14 15:59:23:578 CET] 3c89a97a SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Use outer join fetching: true
[2005-01-14 15:59:23:578 CET] 3c89a97a ConnectionPro I net.sf.hibernate.connection.ConnectionProviderFactory Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceConnectionProvider
[2005-01-14 15:59:23:594 CET] 3c89a97a TransactionMa I net.sf.hibernate.transaction.TransactionManagerLookupFactory No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
[2005-01-14 15:59:24:438 CET] 3c89a97a WSRdbDataSour I DSRA8203I: Database product name : Oracle
[2005-01-14 15:59:24:453 CET] 3c89a97a WSRdbDataSour I DSRA8204I: Database product version : Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
[2005-01-14 15:59:24:453 CET] 3c89a97a WSRdbDataSour I DSRA8205I: JDBC driver name : Oracle JDBC driver
[2005-01-14 15:59:24:453 CET] 3c89a97a WSRdbDataSour I DSRA8206I: JDBC driver version : 9.2.0.3.0
[2005-01-14 15:59:24:922 CET] 3c89a97a SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Use scrollable result sets: true
[2005-01-14 15:59:24:922 CET] 3c89a97a SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Use JDBC3 getGeneratedKeys(): false
[2005-01-14 15:59:24:922 CET] 3c89a97a SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Optimize cache for minimal puts: false
[2005-01-14 15:59:24:922 CET] 3c89a97a SettingsFacto I net.sf.hibernate.cfg.SettingsFactory echoing all SQL to stdout
[2005-01-14 15:59:24:938 CET] 3c89a97a SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Query language substitutions: {}
[2005-01-14 15:59:24:938 CET] 3c89a97a SettingsFacto I net.sf.hibernate.cfg.SettingsFactory cache provider: net.sf.hibernate.cache.EhCacheProvider
[2005-01-14 15:59:24:938 CET] 3c89a97a Configuration I net.sf.hibernate.cfg.Configuration instantiating and configuring caches
[2005-01-14 15:59:25:156 CET] 3c89a97a SessionFactor I net.sf.hibernate.impl.SessionFactoryImpl building session factory
[2005-01-14 15:59:26:766 CET] 3c89a97a SessionFactor I net.sf.hibernate.impl.SessionFactoryObjectFactory Not binding factory to JNDI, no JNDI name configured
[2005-01-14 15:59:26:766 CET] 3c89a97a DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory Creating shared instance of singleton bean 'soiDao'
[2005-01-14 15:59:26:953 CET] 3c89a97a XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefinitionReader Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
[2005-01-14 15:59:26:984 CET] 3c89a97a XmlBeanFactor I org.springframework.beans.factory.xml.XmlBeanFactory Creating shared instance of singleton bean 'DB2'
[2005-01-14 15:59:27:000 CET] 3c89a97a XmlBeanFactor I org.springframework.beans.factory.xml.XmlBeanFactory Creating shared instance of singleton bean 'HSQL'
[2005-01-14 15:59:27:000 CET] 3c89a97a XmlBeanFactor I org.springframework.beans.factory.xml.XmlBeanFactory Creating shared instance of singleton bean 'MS-SQL'
[2005-01-14 15:59:27:000 CET] 3c89a97a XmlBeanFactor I org.springframework.beans.factory.xml.XmlBeanFactory Creating shared instance of singleton bean 'MySQL'
[2005-01-14 15:59:27:000 CET] 3c89a97a XmlBeanFactor I org.springframework.beans.factory.xml.XmlBeanFactory Creating shared instance of singleton bean 'Oracle'
[2005-01-14 15:59:27:000 CET] 3c89a97a XmlBeanFactor I org.springframework.beans.factory.xml.XmlBeanFactory Creating shared instance of singleton bean 'Informix'
[2005-01-14 15:59:27:000 CET] 3c89a97a XmlBeanFactor I org.springframework.beans.factory.xml.XmlBeanFactory Creating shared instance of singleton bean 'PostgreSQL'
[2005-01-14 15:59:27:016 CET] 3c89a97a XmlBeanFactor I org.springframework.beans.factory.xml.XmlBeanFactory Creating shared instance of singleton bean 'Sybase'
[2005-01-14 15:59:27:016 CET] 3c89a97a SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFactory SQLErrorCodes loaded: [HSQL Database Engine, Oracle, Sybase SQL Server, Informix Dynamic Server, Microsoft SQL Server, PostgreSQL, MySQL, DB2*]
[2005-01-14 15:59:27:047 CET] 3c89a97a DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory Creating shared instance of singleton bean 'segmentDao'
[2005-01-14 15:59:27:234 CET] 3c89a97a CollectionFac I org.springframework.core.CollectionFactory Using JDK 1.4 collections
[2005-01-14 15:59:27:297 CET] 3c89a97a DefaultListab I org.springframework.beans.factory.support.DefaultListableBeanFactory Creating shared instance of singleton bean 'buyingAgreementFacade'
[2005-01-14 15:59:27:453 CET] 3c89a97a ContextLoader I org.springframework.web.context.ContextLoader Using context class [org.springframework.web.context.support.XmlWebApplicationContext] for root WebApplicationContext
[2005-01-14 15:59:27:453 CET] 3c89a97a ContextLoader I org.springframework.web.context.ContextLoader Root WebApplicationContext: initialization completed in 6937 ms
[2005-01-14 15:59:27:469 CET] 3c89a97a LocalTranCoor E WLTC0033E: Resource jdbc/CPC_DS rolled back in cleanup of unresolved LocalTransactionContainment.
[2005-01-14 15:59:27:500 CET] 3c89a97a LocalTranCoor E WLTC0032E: One or more resources rolled back. An unresolved LocalTransactionContainment had an unresolved action of rollback.
[2005-01-14 15:59:27:500 CET] 3c89a97a WebAppTransac E WTRN0043I: LocalTransaction rolled-back due to setRollbackOnly.
[2005-01-14 15:59:27:578 CET] 3c89a97a WebGroup E SRVE0020E: [Servlet Error]-[EJBContextLoaderServlet]: Failed to load servlet: com.ibm.ws.LocalTransaction.RolledbackException
at com.ibm.ws.LocalTransaction.LocalTranCoordImpl.cleanup(LocalTranCoordImpl.java:1073)
at com.ibm.ws.webcontainer.webapp.WebAppTransactionCollaborator.postInvoke(WebAppTransactionCollaborator.java:249)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.addServlet(WebAppServletManager.java:885)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:224)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:542)
at com.ibm.ws.webcontainer.webapp.WebApp.loadServletManager(WebApp.java:1277)
at com.ibm.ws.webcontainer.webapp.WebApp.init(WebApp.java:283)
at com.ibm.ws.webcontainer.srt.WebGroup.loadWebApp(WebGroup.java:387)
at com.ibm.ws.webcontainer.srt.WebGroup.init(WebGroup.java:209)
at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:987)
at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:136)
at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:356)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:418)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:787)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:354)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:575)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:271)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:249)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:125)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)
[2005-01-14 15:59:27:578 CET] 3c89a97a WebAppServlet E SRVE0183E: LocalTransaction rolled-back due to setRollbackOnly