PDA

View Full Version : URGENT HELP NEEDED: EJB CMT to Spring to Hibernate > Tx E


Loumeister
Aug 13th, 2004, 03:13 AM
Well, looks like I'm the first poster in this category so hopefully this will be a worthy first post! :lol:

Okay, I have CMT via an WL SLSB connecting to Hibernate DAO POJOs. All was really good in this scenario until I encountered the error below. This error only happens on some of my DAO CRUD ops and not all, could be saves or reads, doesn't matter, it will happen. It seems like the session isn't able to synchronize and thus rolls back.

Does anyone have any clues why this could be happening?

Thanks,
Lou

<Aug 12, 2004 11:49:14 PM PDT> <Error> <EJB> <BEA-010026> <Exception occurred du
ring commit of transaction Name=[EJB com.bea.wlw.runtime.core.bean.SyncDispatche
rBean.invoke(com.bea.wlw.runtime.core.request.Requ est)],Xid=BEA1-00C4744D618826C
12C0A(11642915),Status=Rolled back. [Reason=weblogic.transaction.internal.AppSet
RollbackOnlyException],numRepliesOwedMe=0,numRepli esOwedOthers=0,seconds since b
egin=35,seconds left=60,XAServerResourceInfo[weblogic.jdbc.wrapper .JTSXAResource
Impl]=(ServerResourceInfo[weblogic.jdbc.wrapper.JT SXAResourceImpl]=(state=rolled
back,assigned=cgServer),xar=weblogic.jdbc.wrapper. JTSXAResourceImpl@195cba2,re-R
egistered = false),XAServerResourceInfo[JMS_cgJMSStore]=(Serve rResourceInfo[JMS_
cgJMSStore]=(state=rolledback,assigned=cgServer),x ar=JMS_cgJMSStore,re-Registere
d = false),SCInfo[integration+cgServer]=(state=rolledb ack),properties=({weblogic
.transaction.name=[EJB com.bea.wlw.runtime.core.bean.SyncDispatcherBean.i nvoke(c
om.bea.wlw.runtime.core.request.Request)], weblogic.jdbc=t3://172.24.171.49:7001
}),OwnerTransactionManager=ServerTM[ServerCoordina torDescriptor=(CoordinatorURL=
cgServer+172.24.171.49:7001+integration+t3+, XAResources={JMS_FileStore, integra
tion.cgServer.WebLogic DBMS Adapter Built with ADK_sampleApp.FunctionDemo.Custom
erMgmt.Default.Default, weblogic.jdbc.wrapper.JTSXAResourceImpl, JMS_cgJMSStore}
,NonXAResources={})],CoordinatorURL=cgServer+172.2 4.171.49:7001+integration+t3+)
: weblogic.transaction.internal.AppSetRollbackOnlyEx ception
at weblogic.transaction.internal.TransactionImpl.setR ollbackOnly(Transac
tionImpl.java:504)
at weblogic.transaction.internal.TransactionManagerIm pl.setRollbackOnly(
TransactionManagerImpl.java:337)
at weblogic.transaction.internal.TransactionManagerIm pl.setRollbackOnly(
TransactionManagerImpl.java:331)
at org.springframework.orm.hibernate.SessionFactoryUt ils$JtaSessionSynch
ronization.beforeCompletion(SessionFactoryUtils.ja va:475)
at weblogic.transaction.internal.ServerSCInfo.callBef oreCompletions(Serv
erSCInfo.java:1010)
at weblogic.transaction.internal.ServerSCInfo.startPr ePrepareAndChain(Se
rverSCInfo.java:115)
at weblogic.transaction.internal.ServerTransactionImp l.localPrePrepareAn
dChain(ServerTransactionImpl.java:1184)
at weblogic.transaction.internal.ServerTransactionImp l.globalPrePrepare(
ServerTransactionImpl.java:1910)
at weblogic.transaction.internal.ServerTransactionImp l.internalCommit(Se
rverTransactionImpl.java:273)
at weblogic.transaction.internal.ServerTransactionImp l.commit(ServerTran
sactionImpl.java:244)
at weblogic.ejb20.internal.BaseEJBObject.postInvoke(B aseEJBObject.java:2
99)
at weblogic.ejb20.internal.StatelessEJBObject.postInv oke(StatelessEJBObj
ect.java:140)
at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl 8_EOImpl.invoke(Syn
cDispatcher_k1mrl8_EOImpl.java:110)
at com.bea.wlw.runtime.core.dispatcher.Dispatcher.rem oteDispatch(Dispatc
her.java:161)
at com.bea.wlw.runtime.core.dispatcher.Dispatcher.dis patch(Dispatcher.ja
va:49)
at com.bea.wlw.runtime.core.dispatcher.HttpServerHelp er.executePostReque
st(HttpServerHelper.java:713)
at com.bea.wlw.runtime.core.dispatcher.HttpServer.doP ost(HttpServer.java
:49)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletI nvocationAction.run
(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
pl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
pl.java:315)
at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationActio
n.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:
118)
at weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppSe
rvletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestIm
pl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:178)
--------------- nested within: ------------------
weblogic.transaction.RollbackException: Unknown reason - with nested exception:
[weblogic.transaction.internal.AppSetRollbackOnlyE xception]
at weblogic.transaction.internal.TransactionImpl.thro wRollbackException(
TransactionImpl.java:1644)
at weblogic.transaction.internal.ServerTransactionImp l.internalCommit(Se
rverTransactionImpl.java:323)
at weblogic.transaction.internal.ServerTransactionImp l.commit(ServerTran
sactionImpl.java:244)
at weblogic.ejb20.internal.BaseEJBObject.postInvoke(B aseEJBObject.java:2
99)
at weblogic.ejb20.internal.StatelessEJBObject.postInv oke(StatelessEJBObj
ect.java:140)
at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl 8_EOImpl.invoke(Syn
cDispatcher_k1mrl8_EOImpl.java:110)
at com.bea.wlw.runtime.core.dispatcher.Dispatcher.rem oteDispatch(Dispatc
her.java:161)
at com.bea.wlw.runtime.core.dispatcher.Dispatcher.dis patch(Dispatcher.ja
va:49)
at com.bea.wlw.runtime.core.dispatcher.HttpServerHelp er.executePostReque
st(HttpServerHelper.java:713)
at com.bea.wlw.runtime.core.dispatcher.HttpServer.doP ost(HttpServer.java
:49)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletI nvocationAction.run
(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
pl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
pl.java:315)
at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationActio
n.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:
118)
at weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppSe
rvletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestIm
pl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:178)
.>
<Aug 12, 2004 11:49:14 PM PDT> <Error> <WLW> <000000> <Returning HTTP=500 due to
httpWriteFault msg=null,detail=null
javax.transaction.TransactionRolledbackException: Exception while commiting Tx :
Name=[EJB com.bea.wlw.runtime.core.bean.SyncDispatcherBean.i nvoke(com.bea.wlw.r
untime.core.request.Request)],Xid=BEA1-00C4744D618826C12C0A(11642915),Status=Rol
led back. [Reason=weblogic.transaction.internal.AppSetRollba ckOnlyException],num
RepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=35,seconds left=60,XA
ServerResourceInfo[weblogic.jdbc.wrapper.JTSXAReso urceImpl]=(ServerResourceInfo[
weblogic.jdbc.wrapper.JTSXAResourceImpl]=(state=ro lledback,assigned=cgServer),xa
r=weblogic.jdbc.wrapper.JTSXAResourceImpl@195cba2, re-Registered = false),XAServe
rResourceInfo[JMS_cgJMSStore]=(ServerResourceInfo[ JMS_cgJMSStore]=(state=rolledb
ack,assigned=cgServer),xar=JMS_cgJMSStore,re-Registered = false),SCInfo[integrat
ion+cgServer]=(state=rolledback),properties=({webl ogic.transaction.name=[EJB com
.bea.wlw.runtime.core.bean.SyncDispatcherBean.invo ke(com.bea.wlw.runtime.core.re
quest.Request)], weblogic.jdbc=t3://172.24.171.49:7001}),OwnerTransactionManager
=ServerTM[ServerCoordinatorDescriptor=(Coordinator URL=cgServer+172.24.171.49:700
1+integration+t3+, XAResources={JMS_FileStore, integration.cgServer.WebLogic DBM
S Adapter Built with ADK_sampleApp.FunctionDemo.CustomerMgmt.Default.De fault, we
blogic.jdbc.wrapper.JTSXAResourceImpl, JMS_cgJMSStore},NonXAResources={})],Coord
inatorURL=cgServer+172.24.171.49:7001+integration+ t3+): weblogic.transaction.int
ernal.AppSetRollbackOnlyException
at weblogic.transaction.internal.TransactionImpl.setR ollbackOnly(Transac
tionImpl.java:504)
at weblogic.transaction.internal.TransactionManagerIm pl.setRollbackOnly(
TransactionManagerImpl.java:337)
at weblogic.transaction.internal.TransactionManagerIm pl.setRollbackOnly(
TransactionManagerImpl.java:331)
at org.springframework.orm.hibernate.SessionFactoryUt ils$JtaSessionSynch
ronization.beforeCompletion(SessionFactoryUtils.ja va:475)
at weblogic.transaction.internal.ServerSCInfo.callBef oreCompletions(Serv
erSCInfo.java:1010)
at weblogic.transaction.internal.ServerSCInfo.startPr ePrepareAndChain(Se
rverSCInfo.java:115)
at weblogic.transaction.internal.ServerTransactionImp l.localPrePrepareAn
dChain(ServerTransactionImpl.java:1184)
at weblogic.transaction.internal.ServerTransactionImp l.globalPrePrepare(
ServerTransactionImpl.java:1910)
at weblogic.transaction.internal.ServerTransactionImp l.internalCommit(Se
rverTransactionImpl.java:273)
at weblogic.transaction.internal.ServerTransactionImp l.commit(ServerTran
sactionImpl.java:244)
at weblogic.ejb20.internal.BaseEJBObject.postInvoke(B aseEJBObject.java:2
99)
at weblogic.ejb20.internal.StatelessEJBObject.postInv oke(StatelessEJBObj
ect.java:140)
at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl 8_EOImpl.invoke(Syn
cDispatcher_k1mrl8_EOImpl.java:110)
at com.bea.wlw.runtime.core.dispatcher.Dispatcher.rem oteDispatch(Dispatc
her.java:161)
at com.bea.wlw.runtime.core.dispatcher.Dispatcher.dis patch(Dispatcher.ja
va:49)
at com.bea.wlw.runtime.core.dispatcher.HttpServerHelp er.executePostReque
st(HttpServerHelper.java:713)
at com.bea.wlw.runtime.core.dispatcher.HttpServer.doP ost(HttpServer.java
:49)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletI nvocationAction.run
(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
pl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
pl.java:315)
at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationActio
n.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:
118)
at weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppSe
rvletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestIm
pl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:178)
; nested exception is:
weblogic.transaction.internal.AppSetRollbackOnlyEx ception
at weblogic.ejb20.internal.EJBRuntimeUtils.throwTrans actionRolledback(EJ
BRuntimeUtils.java:202)
at weblogic.ejb20.internal.EJBRuntimeUtils.throwRemot eException(EJBRunti
meUtils.java:90)
at weblogic.ejb20.internal.BaseEJBObject.postInvoke(B aseEJBObject.java:3
22)
at weblogic.ejb20.internal.StatelessEJBObject.postInv oke(StatelessEJBObj
ect.java:140)
at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl 8_EOImpl.invoke(Syn
cDispatcher_k1mrl8_EOImpl.java:110)
at com.bea.wlw.runtime.core.dispatcher.Dispatcher.rem oteDispatch(Dispatc
her.java:161)
at com.bea.wlw.runtime.core.dispatcher.Dispatcher.dis patch(Dispatcher.ja
va:49)
at com.bea.wlw.runtime.core.dispatcher.HttpServerHelp er.executePostReque
st(HttpServerHelper.java:713)
at com.bea.wlw.runtime.core.dispatcher.HttpServer.doP ost(HttpServer.java
:49)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletI nvocationAction.run
(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
pl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
pl.java:315)
at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationActio
n.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:
118)
at weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppSe
rvletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestIm
pl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:178)
Caused by: weblogic.transaction.internal.AppSetRollbackOnlyEx ception
at weblogic.transaction.internal.TransactionImpl.setR ollbackOnly(Transac
tionImpl.java:504)
at weblogic.transaction.internal.TransactionManagerIm pl.setRollbackOnly(
TransactionManagerImpl.java:337)
at weblogic.transaction.internal.TransactionManagerIm pl.setRollbackOnly(
TransactionManagerImpl.java:331)
at org.springframework.orm.hibernate.SessionFactoryUt ils$JtaSessionSynch
ronization.beforeCompletion(SessionFactoryUtils.ja va:475)
at weblogic.transaction.internal.ServerSCInfo.callBef oreCompletions(Serv
erSCInfo.java:1010)
at weblogic.transaction.internal.ServerSCInfo.startPr ePrepareAndChain(Se
rverSCInfo.java:115)
at weblogic.transaction.internal.ServerTransactionImp l.localPrePrepareAn
dChain(ServerTransactionImpl.java:1184)
at weblogic.transaction.internal.ServerTransactionImp l.globalPrePrepare(
ServerTransactionImpl.java:1910)
at weblogic.transaction.internal.ServerTransactionImp l.internalCommit(Se
rverTransactionImpl.java:273)
at weblogic.transaction.internal.ServerTransactionImp l.commit(ServerTran
sactionImpl.java:244)
at weblogic.ejb20.internal.BaseEJBObject.postInvoke(B aseEJBObject.java:2
99)
... 18 more
>
applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<!--
- Root application context definition for a web app that uses Hibernate.
- Does not depend on web infrastructure or any web-specific classes!
-
- Assumes running in a J2EE environment in the "myDataSource" definition, as
- it looks for a JNDI DataSource that the Hibernate
- SessionFactory will use to access the database, but that can be replaced easily
- (as noted). Such a context definition can thus be reused in test environments
- or standalone applications without any hassle.
-
- Alternatively, the simple JNDI implementation in org.springframework.jndi.support
- can be leveraged to set up a JNDI environment outside of a J2EE container,
- binding a DataSource instance like DriverManagerDataSource or a Jakarta Commons
- DBCP BasicDataSource to the expected JNDI location.
-->
<beans>
<!-- ========================= GENERAL DEFINITIONS ========================= -->
<!--
- The message source for this context, loaded from localized "messages_xx" files
- in the classpath, i.e. "/WEB-INF/classes/messages.properties" or
- "/WEB-INF/classes/messages_de.properties".
-
- "getMessage" calls to this context will use this source.
- Child contexts can have their own message sources, inheriting all messages from this
- source, being able to define new messages and override ones defined in this source.
-->
<!-- <bean id="messageSource" class="org.springframework.context.support.ResourceBundle MessageSource">-->
<!-- <property name="basename"><value>messages</value></property>-->
<!-- </bean>-->
<!-- ========================= PERSISTENCE DEFINITIONS ========================= -->
<!--
- Makes a JNDI DataSource available as bean reference, assuming a J2EE environment.
- By default, "java:comp/env/" will be prepended if not already specified.
-
- If giving this DataSource to LocalSessionFactoryBean, an alternative DataSource
- could be used here too, e.g. for non-J2EE environments (see "webapp-typical").
- Alternatively, one can omit the context-level DataSource definition, and let
- Hibernate use its own connection provider, specified via Hibernate properties.
-->
<bean id="clmDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>clmDataSource</value></property>
</bean>
<!--Below is the following that you would use when testing outside the J2EE container-->
<!--<bean id="clmDataSource"
class="org.springframework.jdbc.datasource.DriverManagerD ataSource">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@nmad.mitchell.com:1521:nmad</value>
</property>
<property name="username">
<value>clm</value>
</property>
<property name="password">
<value>clm</value>
</property>
</bean>-->
<!--
- Builds a Hibernate SessionFactory and makes it available as bean reference.
- All necessary settings get specified here, without relying on an external
- Hibernate config file like "WEB-INF/classes/hibernate.cfg.xml".
-
- The SessionFactory will use the locally defined DataSource in this context.
- This allows for convenient sharing of transactions with plain JDBC access
- code, if HibernateTransactionManager is explictly given the same DataSource.
-
- This definition could also use a JDBC DataSource specified via Hibernate
- properties. Note that to be able to share transactions with plain JDBC access
- code then, that DataSource would need to be a JNDI one that should match the
- one given to HibernateTransactionManager and data access objects.
-
- This definition can be replaced by a JndiObjectFactoryBean definition for fetching
- a JNDI-bound SessionFactory, but this only makes sense when using Hibernate's
- JCA Connector (not recommended for most types of applications).
-->
<bean id="mySessionFactory"
class="org.springframework.orm.hibernate.LocalSessionFact oryBean">
<property name="dataSource">
<ref local="clmDataSource"/>
</property>
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!--
- Defines a transaction manager for usage in business or data access objects.
- No special treatment by the context, just a bean instance available as reference
- for business objects that want to handle transactions, e.g. via TransactionTemplate.
-
- Needs a SessionFactory reference that it should handle transactions for.
- Can optionally take a DataSource reference that it should use export Hibernate
- transactions for, to be able to share transactions with plain JDBC access code
- on the same database (using the same DataSource as the Hibernate SessionFactory).
-->
<!--Below is the following that you would use when testing outside the J2EE container (no CMT)-->
<!--<bean id="myTransactionManager"
class="org.springframework.orm.hibernate.HibernateTransac tionManager">
<property name="sessionFactory">
<ref local="mySessionFactory"/>
</property>
</bean>-->

<!--
- Alternative transaction manager that accesses the container's transaction manager.
- Can be used as drop-in replacement for HibernateTransactionManager, e.g. when
- needing distributed transactions (i.e. across multiple databases).
-->
<!--<bean id="myTransactionManager"
class="org.springframework.transaction.jta.JtaTransaction Manager"/>-->

<!--Use an AOP interceptor to attach the Hibernate session to CMT for session-per-
- transaction scoping. This way one hibernate session will live with the transaction.-->
<bean id="myHibernateInterceptor"
class="org.springframework.orm.hibernate.HibernateInterce ptor">
<property name="sessionFactory">
<ref bean="mySessionFactory"/>
</property>
</bean>

<bean id="clmAddressDaoTarget" singleton="false"
class="com.mitchell.services.technical.claim.dao.spring.C lmAddressHibernateDao">
<property name="sessionFactory">
<ref local="mySessionFactory"/>
</property>
</bean>
<bean id="clmAddressDao"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.mitchell.services.technical.claim.dao.ClmAddre ssDao</value>
</property>
<property name="interceptorNames">
<list>
<value>myHibernateInterceptor</value>
<value>clmAddressDaoTarget</value>
</list>
</property>
</bean>
// there's more just not listed...

<bean id="claimDaoManager"
class="com.mitchell.services.technical.claim.dao.ClaimDao Mgr">
<property name="clmAddressDao">
<ref local="clmAddressDao"/>
</property>
</bean>
<!-- We don't need to do this since Spring is smart about going JTA if
- it exists, which in our case does when implementing with CMT.
- You would only need this for Spring-based CMT.
-->
<!--<bean id="myClaimService"
class="org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean">
<property name="transactionManager">
<ref bean="myTransactionManager"/>
</property>
<property name="target">
<ref bean="claimDaoManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<!-#-<prop key="someOtherBusinessMethod">
PROPAGATION_MANDATORY</prop>-#->
</props>
</property>
</bean>-->
</beans>


hibernate.config.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory name="ClmSessionFactory">
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.max_fetch_depth">3</property>
<property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.jdbc.use_get_generated_keys">true</property>
<property name="hibernate.jdbc.use_streams_for_binary">true</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.query.substitutions">true 'T', false 'F', yes 'Y', no 'N'</property>
<!--<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JTATransactionFactory
</property>
<property name="jta.UserTransaction">
javax.transaction.UserTransaction
</property>-->
<property name="hibernate.transaction.manager_lookup_class">
net.sf.hibernate.transaction.WeblogicTransactionMa nagerLookup
</property>

<mapping
resource="com/mitchell/services/technical/claim/dao/vo/ClmAddress.hbm.xml"
/>
</session-factory>
</hibernate-configuration>

ericlma
Aug 13th, 2004, 01:07 PM
Definitely interesting stuff.

Looks like you are using WL Integration, which behind the scene has some JMS stuff thrown in for good measure :-) I think in this case you do want to explicitly use Spring's JtaTransactionManager in you Spring config file.

Loumeister
Aug 13th, 2004, 02:45 PM
Thanks...almost too interesting! :cry:

Per this post (http://forum.hibernate.org/viewtopic.php?t=929516) Juergon exclaims that you wouldn't need Spring transaction management, just the WeblogicTransaction manager lookup class I have in my hibernate.cfg.xml. Despite that, I've tried several different permutations, and I still see the same error in the log. At this point, I'm not really sure what I need anymore.

My latest thought is to move the Hibernate session factory into JNDI and use the HibernateUtil that leverages LocalThread to bind the session to the SLSB method call.

Lou

ericlma
Aug 13th, 2004, 03:38 PM
Per this post (http://forum.hibernate.org/viewtopic.php?t=929516) Juergon exclaims that you wouldn't need Spring transaction management, just the WeblogicTransaction manager lookup class I have in my hibernate.cfg.xml.

I have been following the threads you started and participated at the Hibernate Architecture forum and the old Spring Help forum. I am interested in this discussion because I have an app that uses JMS/SLSB EJB in XA TX that I wanted to migrate to Spring. However, unlike your case, I want to get rid of SLSB (replace them by service POJO's) and only keep my MDB's.

Now, I have read all available materials on Spring declarative TX management (Juergen's white paper at hibernate.org, Spring User's Guide, Rod Johnson's new book), however, things are still not clear to me. My question is: if like you I want to use SLSB + DAO + Hibernate, do I even need Spring, if my TX is demarcated by the SLSB and Hibernate SessionFactory knows how to participate in a JTA transaction? I.e., does my DAO class have to extend Spring's HibernateDaoSupport class?


My latest thought is to move the Hibernate session factory into JNDI and use the HibernateUtil that leverages LocalThread to bind the session to the SLSB method call.

So the same question here, do you need Spring at all?

Eric

ericlma
Aug 13th, 2004, 04:02 PM
After re-read Section 2.3.3 of "Hibernate in Action", my believe grows stronger that with a SLSB (CMT) + DAO (Hibernate) architecture, you don't need to use Spring's declarative TX management functionality at all. The only kind of things Spring's HibernateDaoSupport/HibernateTemplate classes do for you in this case is hiding Hibernate's buildSessionFactory(), openSession(), beginTransaction(), Transaction.commit() etc. calls (of course it also wraps HibernateException into Spring's DataAcessException as well).

ericlma
Aug 13th, 2004, 04:24 PM
Per this post (http://forum.hibernate.org/viewtopic.php?t=929516) Juergon exclaims that you wouldn't need Spring transaction management, just the WeblogicTransaction manager lookup class I have in my hibernate.cfg.xml.

OK, it all makes sense now. What Juergen said is right, because Spring AOP-based TX does not add anything extra on top of what Hibernate already does in terms of supporting JTA.

So back to your original exception thrown by WL Integration - you probably want to see what happens in the JMS part (I know it is not your code). Also, you may want to take Spring completely out of the picture while debugging to eliminate the number of variables.

Loumeister
Aug 13th, 2004, 04:28 PM
Right, I don't leverage Spring for transaction management. The only thing I am using Spring for is the DAO framework and the AOP interceptor to manage the Hibernate Sessions for me. What I understand is that Spring's Session utility automagically adds the session to the transaction (whatever flavor that may be) and closes the session when the transaction ends.

I just enabled log4j to see more details, so I'll keep you posted.

Lou

Loumeister
Aug 21st, 2004, 04:42 AM
Just to post back to anyone that might be interested. The issue ended up being more to do with the session being flushed so late as to cause the container to rollback due to a SQLException. The true exception wasn't revealed to me until I turned on debug.

Considering that I can't wait for the session to flush once an attempt to commit takes place, I decided to write a Session.flush() inside my DAOs. In this way, if a SQLException is thrown, my busines tier can catch the exception and handle appropriately. This keeps my business tier clean of any session handling, but still gives me the ability to handle said exceptions.

HTH,
Lou