View Poll Results: Do you use CMT with Spring/ORM?

Voters
30. You may not vote on this poll
  • Yes

    11 36.67%
  • No

    9 30.00%
  • May soon

    2 6.67%
  • EJB's...WTF!!

    8 26.67%
Results 1 to 8 of 8

Thread: URGENT HELP NEEDED: EJB CMT to Spring to Hibernate > Tx E

  1. #1
    Join Date
    Aug 2004
    Posts
    218

    Default URGENT HELP NEEDED: EJB CMT to Spring to Hibernate > Tx E

    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

    Code:
    <Aug 12, 2004 11&#58;49&#58;14 PM PDT> <Error> <EJB> <BEA-010026> <Exception occurred du
    ring commit of transaction Name=&#91;EJB com.bea.wlw.runtime.core.bean.SyncDispatche
    rBean.invoke&#40;com.bea.wlw.runtime.core.request.Request&#41;&#93;,Xid=BEA1-00C4744D618826C
    12C0A&#40;11642915&#41;,Status=Rolled back. &#91;Reason=weblogic.transaction.internal.AppSet
    RollbackOnlyException&#93;,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since b
    egin=35,seconds left=60,XAServerResourceInfo&#91;weblogic.jdbc.wrapper.JTSXAResource
    Impl&#93;=&#40;ServerResourceInfo&#91;weblogic.jdbc.wrapper.JTSXAResourceImpl&#93;=&#40;state=rolled
    back,assigned=cgServer&#41;,xar=weblogic.jdbc.wrapper.JTSXAResourceImpl@195cba2,re-R
    egistered = false&#41;,XAServerResourceInfo&#91;JMS_cgJMSStore&#93;=&#40;ServerResourceInfo&#91;JMS_
    cgJMSStore&#93;=&#40;state=rolledback,assigned=cgServer&#41;,xar=JMS_cgJMSStore,re-Registere
    d = false&#41;,SCInfo&#91;integration+cgServer&#93;=&#40;state=rolledback&#41;,properties=&#40;&#123;weblogic
    .transaction.name=&#91;EJB com.bea.wlw.runtime.core.bean.SyncDispatcherBean.invoke&#40;c
    om.bea.wlw.runtime.core.request.Request&#41;&#93;, weblogic.jdbc=t3&#58;//172.24.171.49&#58;7001
    &#125;&#41;,OwnerTransactionManager=ServerTM&#91;ServerCoordinatorDescriptor=&#40;CoordinatorURL=
    cgServer+172.24.171.49&#58;7001+integration+t3+, XAResources=&#123;JMS_FileStore, integra
    tion.cgServer.WebLogic DBMS Adapter Built with ADK_sampleApp.FunctionDemo.Custom
    erMgmt.Default.Default, weblogic.jdbc.wrapper.JTSXAResourceImpl, JMS_cgJMSStore&#125;
    ,NonXAResources=&#123;&#125;&#41;&#93;,CoordinatorURL=cgServer+172.24.171.49&#58;7001+integration+t3+&#41;
    &#58; weblogic.transaction.internal.AppSetRollbackOnlyException
            at weblogic.transaction.internal.TransactionImpl.setRollbackOnly&#40;Transac
    tionImpl.java&#58;504&#41;
            at weblogic.transaction.internal.TransactionManagerImpl.setRollbackOnly&#40;
    TransactionManagerImpl.java&#58;337&#41;
            at weblogic.transaction.internal.TransactionManagerImpl.setRollbackOnly&#40;
    TransactionManagerImpl.java&#58;331&#41;
            at org.springframework.orm.hibernate.SessionFactoryUtils$JtaSessionSynch
    ronization.beforeCompletion&#40;SessionFactoryUtils.java&#58;475&#41;
            at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions&#40;Serv
    erSCInfo.java&#58;1010&#41;
            at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain&#40;Se
    rverSCInfo.java&#58;115&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAn
    dChain&#40;ServerTransactionImpl.java&#58;1184&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare&#40;
    ServerTransactionImpl.java&#58;1910&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.internalCommit&#40;Se
    rverTransactionImpl.java&#58;273&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.commit&#40;ServerTran
    sactionImpl.java&#58;244&#41;
            at weblogic.ejb20.internal.BaseEJBObject.postInvoke&#40;BaseEJBObject.java&#58;2
    99&#41;
            at weblogic.ejb20.internal.StatelessEJBObject.postInvoke&#40;StatelessEJBObj
    ect.java&#58;140&#41;
            at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl8_EOImpl.invoke&#40;Syn
    cDispatcher_k1mrl8_EOImpl.java&#58;110&#41;
            at com.bea.wlw.runtime.core.dispatcher.Dispatcher.remoteDispatch&#40;Dispatc
    her.java&#58;161&#41;
            at com.bea.wlw.runtime.core.dispatcher.Dispatcher.dispatch&#40;Dispatcher.ja
    va&#58;49&#41;
            at com.bea.wlw.runtime.core.dispatcher.HttpServerHelper.executePostReque
    st&#40;HttpServerHelper.java&#58;713&#41;
            at com.bea.wlw.runtime.core.dispatcher.HttpServer.doPost&#40;HttpServer.java
    &#58;49&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;760&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;853&#41;
            at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
    &#40;ServletStubImpl.java&#58;996&#41;
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet&#40;ServletStubIm
    pl.java&#58;419&#41;
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet&#40;ServletStubIm
    pl.java&#58;315&#41;
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
    n.run&#40;WebAppServletContext.java&#58;6452&#41;
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs&#40;Authenticate
    dSubject.java&#58;321&#41;
            at weblogic.security.service.SecurityManager.runAs&#40;SecurityManager.java&#58;
    118&#41;
            at weblogic.servlet.internal.WebAppServletContext.invokeServlet&#40;WebAppSe
    rvletContext.java&#58;3661&#41;
            at weblogic.servlet.internal.ServletRequestImpl.execute&#40;ServletRequestIm
    pl.java&#58;2630&#41;
            at weblogic.kernel.ExecuteThread.execute&#40;ExecuteThread.java&#58;219&#41;
            at weblogic.kernel.ExecuteThread.run&#40;ExecuteThread.java&#58;178&#41;
    --------------- nested within&#58; ------------------
    weblogic.transaction.RollbackException&#58; Unknown reason - with nested exception&#58;
    &#91;weblogic.transaction.internal.AppSetRollbackOnlyException&#93;
            at weblogic.transaction.internal.TransactionImpl.throwRollbackException&#40;
    TransactionImpl.java&#58;1644&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.internalCommit&#40;Se
    rverTransactionImpl.java&#58;323&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.commit&#40;ServerTran
    sactionImpl.java&#58;244&#41;
            at weblogic.ejb20.internal.BaseEJBObject.postInvoke&#40;BaseEJBObject.java&#58;2
    99&#41;
            at weblogic.ejb20.internal.StatelessEJBObject.postInvoke&#40;StatelessEJBObj
    ect.java&#58;140&#41;
            at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl8_EOImpl.invoke&#40;Syn
    cDispatcher_k1mrl8_EOImpl.java&#58;110&#41;
            at com.bea.wlw.runtime.core.dispatcher.Dispatcher.remoteDispatch&#40;Dispatc
    her.java&#58;161&#41;
            at com.bea.wlw.runtime.core.dispatcher.Dispatcher.dispatch&#40;Dispatcher.ja
    va&#58;49&#41;
            at com.bea.wlw.runtime.core.dispatcher.HttpServerHelper.executePostReque
    st&#40;HttpServerHelper.java&#58;713&#41;
            at com.bea.wlw.runtime.core.dispatcher.HttpServer.doPost&#40;HttpServer.java
    &#58;49&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;760&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;853&#41;
            at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
    &#40;ServletStubImpl.java&#58;996&#41;
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet&#40;ServletStubIm
    pl.java&#58;419&#41;
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet&#40;ServletStubIm
    pl.java&#58;315&#41;
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
    n.run&#40;WebAppServletContext.java&#58;6452&#41;
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs&#40;Authenticate
    dSubject.java&#58;321&#41;
            at weblogic.security.service.SecurityManager.runAs&#40;SecurityManager.java&#58;
    118&#41;
            at weblogic.servlet.internal.WebAppServletContext.invokeServlet&#40;WebAppSe
    rvletContext.java&#58;3661&#41;
            at weblogic.servlet.internal.ServletRequestImpl.execute&#40;ServletRequestIm
    pl.java&#58;2630&#41;
            at weblogic.kernel.ExecuteThread.execute&#40;ExecuteThread.java&#58;219&#41;
            at weblogic.kernel.ExecuteThread.run&#40;ExecuteThread.java&#58;178&#41;
    .>
    <Aug 12, 2004 11&#58;49&#58;14 PM PDT> <Error> <WLW> <000000> <Returning HTTP=500 due to
     httpWriteFault msg=null,detail=null
    javax.transaction.TransactionRolledbackException&#58; Exception while commiting Tx &#58;
     Name=&#91;EJB com.bea.wlw.runtime.core.bean.SyncDispatcherBean.invoke&#40;com.bea.wlw.r
    untime.core.request.Request&#41;&#93;,Xid=BEA1-00C4744D618826C12C0A&#40;11642915&#41;,Status=Rol
    led back. &#91;Reason=weblogic.transaction.internal.AppSetRollbackOnlyException&#93;,num
    RepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=35,seconds left=60,XA
    ServerResourceInfo&#91;weblogic.jdbc.wrapper.JTSXAResourceImpl&#93;=&#40;ServerResourceInfo&#91;
    weblogic.jdbc.wrapper.JTSXAResourceImpl&#93;=&#40;state=rolledback,assigned=cgServer&#41;,xa
    r=weblogic.jdbc.wrapper.JTSXAResourceImpl@195cba2,re-Registered = false&#41;,XAServe
    rResourceInfo&#91;JMS_cgJMSStore&#93;=&#40;ServerResourceInfo&#91;JMS_cgJMSStore&#93;=&#40;state=rolledb
    ack,assigned=cgServer&#41;,xar=JMS_cgJMSStore,re-Registered = false&#41;,SCInfo&#91;integrat
    ion+cgServer&#93;=&#40;state=rolledback&#41;,properties=&#40;&#123;weblogic.transaction.name=&#91;EJB com
    .bea.wlw.runtime.core.bean.SyncDispatcherBean.invoke&#40;com.bea.wlw.runtime.core.re
    quest.Request&#41;&#93;, weblogic.jdbc=t3&#58;//172.24.171.49&#58;7001&#125;&#41;,OwnerTransactionManager
    =ServerTM&#91;ServerCoordinatorDescriptor=&#40;CoordinatorURL=cgServer+172.24.171.49&#58;700
    1+integration+t3+, XAResources=&#123;JMS_FileStore, integration.cgServer.WebLogic DBM
    S Adapter Built with ADK_sampleApp.FunctionDemo.CustomerMgmt.Default.Default, we
    blogic.jdbc.wrapper.JTSXAResourceImpl, JMS_cgJMSStore&#125;,NonXAResources=&#123;&#125;&#41;&#93;,Coord
    inatorURL=cgServer+172.24.171.49&#58;7001+integration+t3+&#41;&#58; weblogic.transaction.int
    ernal.AppSetRollbackOnlyException
            at weblogic.transaction.internal.TransactionImpl.setRollbackOnly&#40;Transac
    tionImpl.java&#58;504&#41;
            at weblogic.transaction.internal.TransactionManagerImpl.setRollbackOnly&#40;
    TransactionManagerImpl.java&#58;337&#41;
            at weblogic.transaction.internal.TransactionManagerImpl.setRollbackOnly&#40;
    TransactionManagerImpl.java&#58;331&#41;
            at org.springframework.orm.hibernate.SessionFactoryUtils$JtaSessionSynch
    ronization.beforeCompletion&#40;SessionFactoryUtils.java&#58;475&#41;
            at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions&#40;Serv
    erSCInfo.java&#58;1010&#41;
            at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain&#40;Se
    rverSCInfo.java&#58;115&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAn
    dChain&#40;ServerTransactionImpl.java&#58;1184&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare&#40;
    ServerTransactionImpl.java&#58;1910&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.internalCommit&#40;Se
    rverTransactionImpl.java&#58;273&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.commit&#40;ServerTran
    sactionImpl.java&#58;244&#41;
            at weblogic.ejb20.internal.BaseEJBObject.postInvoke&#40;BaseEJBObject.java&#58;2
    99&#41;
            at weblogic.ejb20.internal.StatelessEJBObject.postInvoke&#40;StatelessEJBObj
    ect.java&#58;140&#41;
            at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl8_EOImpl.invoke&#40;Syn
    cDispatcher_k1mrl8_EOImpl.java&#58;110&#41;
            at com.bea.wlw.runtime.core.dispatcher.Dispatcher.remoteDispatch&#40;Dispatc
    her.java&#58;161&#41;
            at com.bea.wlw.runtime.core.dispatcher.Dispatcher.dispatch&#40;Dispatcher.ja
    va&#58;49&#41;
            at com.bea.wlw.runtime.core.dispatcher.HttpServerHelper.executePostReque
    st&#40;HttpServerHelper.java&#58;713&#41;
            at com.bea.wlw.runtime.core.dispatcher.HttpServer.doPost&#40;HttpServer.java
    &#58;49&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;760&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;853&#41;
            at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
    &#40;ServletStubImpl.java&#58;996&#41;
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet&#40;ServletStubIm
    pl.java&#58;419&#41;
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet&#40;ServletStubIm
    pl.java&#58;315&#41;
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
    n.run&#40;WebAppServletContext.java&#58;6452&#41;
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs&#40;Authenticate
    dSubject.java&#58;321&#41;
            at weblogic.security.service.SecurityManager.runAs&#40;SecurityManager.java&#58;
    118&#41;
            at weblogic.servlet.internal.WebAppServletContext.invokeServlet&#40;WebAppSe
    rvletContext.java&#58;3661&#41;
            at weblogic.servlet.internal.ServletRequestImpl.execute&#40;ServletRequestIm
    pl.java&#58;2630&#41;
            at weblogic.kernel.ExecuteThread.execute&#40;ExecuteThread.java&#58;219&#41;
            at weblogic.kernel.ExecuteThread.run&#40;ExecuteThread.java&#58;178&#41;
    ; nested exception is&#58;
            weblogic.transaction.internal.AppSetRollbackOnlyException
            at weblogic.ejb20.internal.EJBRuntimeUtils.throwTransactionRolledback&#40;EJ
    BRuntimeUtils.java&#58;202&#41;
            at weblogic.ejb20.internal.EJBRuntimeUtils.throwRemoteException&#40;EJBRunti
    meUtils.java&#58;90&#41;
            at weblogic.ejb20.internal.BaseEJBObject.postInvoke&#40;BaseEJBObject.java&#58;3
    22&#41;
            at weblogic.ejb20.internal.StatelessEJBObject.postInvoke&#40;StatelessEJBObj
    ect.java&#58;140&#41;
            at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl8_EOImpl.invoke&#40;Syn
    cDispatcher_k1mrl8_EOImpl.java&#58;110&#41;
            at com.bea.wlw.runtime.core.dispatcher.Dispatcher.remoteDispatch&#40;Dispatc
    her.java&#58;161&#41;
            at com.bea.wlw.runtime.core.dispatcher.Dispatcher.dispatch&#40;Dispatcher.ja
    va&#58;49&#41;
            at com.bea.wlw.runtime.core.dispatcher.HttpServerHelper.executePostReque
    st&#40;HttpServerHelper.java&#58;713&#41;
            at com.bea.wlw.runtime.core.dispatcher.HttpServer.doPost&#40;HttpServer.java
    &#58;49&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;760&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;853&#41;
            at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
    &#40;ServletStubImpl.java&#58;996&#41;
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet&#40;ServletStubIm
    pl.java&#58;419&#41;
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet&#40;ServletStubIm
    pl.java&#58;315&#41;
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
    n.run&#40;WebAppServletContext.java&#58;6452&#41;
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs&#40;Authenticate
    dSubject.java&#58;321&#41;
            at weblogic.security.service.SecurityManager.runAs&#40;SecurityManager.java&#58;
    118&#41;
            at weblogic.servlet.internal.WebAppServletContext.invokeServlet&#40;WebAppSe
    rvletContext.java&#58;3661&#41;
            at weblogic.servlet.internal.ServletRequestImpl.execute&#40;ServletRequestIm
    pl.java&#58;2630&#41;
            at weblogic.kernel.ExecuteThread.execute&#40;ExecuteThread.java&#58;219&#41;
            at weblogic.kernel.ExecuteThread.run&#40;ExecuteThread.java&#58;178&#41;
    Caused by&#58; weblogic.transaction.internal.AppSetRollbackOnlyException
            at weblogic.transaction.internal.TransactionImpl.setRollbackOnly&#40;Transac
    tionImpl.java&#58;504&#41;
            at weblogic.transaction.internal.TransactionManagerImpl.setRollbackOnly&#40;
    TransactionManagerImpl.java&#58;337&#41;
            at weblogic.transaction.internal.TransactionManagerImpl.setRollbackOnly&#40;
    TransactionManagerImpl.java&#58;331&#41;
            at org.springframework.orm.hibernate.SessionFactoryUtils$JtaSessionSynch
    ronization.beforeCompletion&#40;SessionFactoryUtils.java&#58;475&#41;
            at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions&#40;Serv
    erSCInfo.java&#58;1010&#41;
            at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain&#40;Se
    rverSCInfo.java&#58;115&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAn
    dChain&#40;ServerTransactionImpl.java&#58;1184&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare&#40;
    ServerTransactionImpl.java&#58;1910&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.internalCommit&#40;Se
    rverTransactionImpl.java&#58;273&#41;
            at weblogic.transaction.internal.ServerTransactionImpl.commit&#40;ServerTran
    sactionImpl.java&#58;244&#41;
            at weblogic.ejb20.internal.BaseEJBObject.postInvoke&#40;BaseEJBObject.java&#58;2
    99&#41;
            ... 18 more
    >
    applicationContext.xml
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
    	"http&#58;//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
      - &#40;as noted&#41;. 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.ResourceBundleMessageSource">-->
    	<!--		<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&#58;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 &#40;see "webapp-typical"&#41;.
    	  - 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.DriverManagerDataSource">
    		<property name="driverClassName">
    			<value>oracle.jdbc.driver.OracleDriver</value>
    		</property>
    		<property name="url">
    			<value>jdbc&#58;oracle&#58;thin&#58;@nmad.mitchell.com&#58;1521&#58;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 &#40;not recommended for most types of applications&#41;.
    	  -->
    	<bean id="mySessionFactory" 
    		class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref local="clmDataSource"/>
    		</property>
    		<property name="configLocation">
    			<value>classpath&#58;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 &#40;using the same DataSource as the Hibernate SessionFactory&#41;.
    	  -->	  
    	<!--Below is the following that you would use when testing outside the J2EE container &#40;no CMT&#41;-->
    	<!--<bean id="myTransactionManager" 
    		class="org.springframework.orm.hibernate.HibernateTransactionManager">
    		<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 &#40;i.e. across multiple databases&#41;.
    	  -->
    	<!--<bean id="myTransactionManager" 
    		class="org.springframework.transaction.jta.JtaTransactionManager"/>-->
    		
    	<!--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.HibernateInterceptor">
    		<property name="sessionFactory">
    			<ref bean="mySessionFactory"/>
    		</property>
    	</bean>
    	
    	<bean id="clmAddressDaoTarget" singleton="false" 
    		class="com.mitchell.services.technical.claim.dao.spring.ClmAddressHibernateDao">
    		<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.ClmAddressDao</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.ClaimDaoMgr">
    		<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.TransactionProxyFactoryBean">
    		<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&#58;//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.WeblogicTransactionManagerLookup
    		</property>
    		
    		<mapping 
    			resource="com/mitchell/services/technical/claim/dao/vo/ClmAddress.hbm.xml" 
    			/>
    	</session-factory>
    </hibernate-configuration>

  2. #2
    Join Date
    Aug 2004
    Location
    New York, USA
    Posts
    6

    Default Re: URGENT HELP NEEDED: EJB CMT to Spring to Hibernate >

    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.

  3. #3
    Join Date
    Aug 2004
    Posts
    218

    Default Re: URGENT HELP NEEDED: EJB CMT to Spring to Hibernate >

    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

  4. #4
    Join Date
    Aug 2004
    Location
    New York, USA
    Posts
    6

    Default Re: URGENT HELP NEEDED: EJB CMT to Spring to Hibernate >

    Quote Originally Posted by Loumeister
    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?

    Quote Originally Posted by Loumeister
    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

  5. #5
    Join Date
    Aug 2004
    Location
    New York, USA
    Posts
    6

    Default Re: URGENT HELP NEEDED: EJB CMT to Spring to Hibernate >

    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).

  6. #6
    Join Date
    Aug 2004
    Location
    New York, USA
    Posts
    6

    Default Re: URGENT HELP NEEDED: EJB CMT to Spring to Hibernate >

    Quote Originally Posted by Loumeister
    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.

  7. #7
    Join Date
    Aug 2004
    Posts
    218

    Default

    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

  8. #8
    Join Date
    Aug 2004
    Posts
    218

    Default

    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

Similar Threads

  1. Replies: 5
    Last Post: Feb 3rd, 2009, 05:19 AM
  2. Replies: 3
    Last Post: Aug 16th, 2007, 12:10 PM
  3. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 0
    Last Post: Jan 26th, 2005, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •