Announcement Announcement Module
Collapse
No announcement yet.
Websphere 7, Spring 3.1, Hibernate 4 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Websphere 7, Spring 3.1, Hibernate 4

    Websphere 7
    Spring 3.1
    Hibernate 4

    Have a web app using above. The data source is configured and works in websphere. In fact the calls do succeed up to a point. It loks though that there is a problem in the session / connection close procedure that is giving problems

    Code:
     WTRN0074E: Exception caught from after_completion synchronization operation: org.hibernate.HibernateException: proxy handle is no longer valid
    This error appears to have happened to others ..

    https://forum.hibernate.org/viewtopic.php?f=1&t=1014673
    though the same problem does not happen with Apache/Tomcat (with changed transaction manager mind u)

    I have have updated Hibernate to nightly (26/3) thinking the the possible problem mentioned https://hibernate.onjira.com/browse/HHH-7090 could be solved using fix.

    any pointers appreciated..

    Daniel

    More details below ..



    Configuration..
    Code:
    <jee:jndi-lookup id="hibernateDataSource" jndi-name="jdbc/Oracle206" resource-ref="true" 
    		cache="true" lookup-on-startup="false" proxy-interface="javax.sql.DataSource" />
    
    
    <util:properties id="hibernateProperties">
    		<prop key="hibernate.dialect">${hibernate.dialect}</prop>
    		<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    		<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
    		<prop key="hibernate.connection.datasource">jdbc/Oracle206</prop>
    		<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
    		<prop key="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform</prop>
    
    	</util:properties>
    
    
    	<tx:advice id="serviceTxAdvice" transaction-manager="transactionManager">
    		<tx:attributes>
    			<!-- all methods starting with 'find' are read-only -->
                <tx:method name="find*" read-only="true"  />
                <!-- other methods  -->
                <tx:method name="*"  propagation="REQUIRED" />
    		</tx:attributes>
    	</tx:advice>
    
    	<aop:config>
    		<aop:pointcut id="commonEndpointServiceMethods"
    			expression="execution(* com.XXX.services.endpoint.common.*.*(..))" />
    		<aop:pointcut id="serviceMethods"
    			expression="execution(* com.XXX.backend.service.*.*(..))" />
    
    		<aop:advisor advice-ref="serviceTxAdvice" pointcut-ref="commonEndpointServiceMethods" />
    		<aop:advisor advice-ref="serviceTxAdvice" pointcut-ref="serviceMethods" />
    
    	</aop:config>
    
    	<bean id="transactionManager"
    		class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />
    Looking in forums, Uow transaction manager and setting the jta platform and factory class are required for Websphere. (using newer jta platform as the older manager_lookup_class? deprecated)

    Hibernate config

    Code:
    	<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    		<property name="dataSource" ref="hibernateDataSource"/>
    		<property name="hibernateProperties" ref="hibernateProperties" />
    		<property name="mappingResources">
    			<list>
    				<value>hibernate_mappings/XXX.hbm.xml</value>
                                     ....
    			</list>
    		</property>
    	</bean>
    Hibernate generic DAO .. getSession using getCurrentSession..
    I dont do any session closing as Im assuming that the AOP transaction wrapper handles this as part of commit.

    Code:
    public Session getSession()
    	{
    		Session session = null;
    		
    		try
    		{
    			session = sessionFactory.getCurrentSession();
    			//m_logger.debug("Got current session");
    		}
    		catch(HibernateException e)
    		{
    			//m_logger.debug("Exception in getting session " + e.getMessage());
    			try
    			{
    				//m_logger.debug("Open new session ..");
    				session = sessionFactory.openSession();
    			}
    			catch(HibernateException ex)
    			{
    				e.printStackTrace();
    			}
    		}
    		
    		return session;
    	}
    Full Stack trace..
    Code:
     WTRN0074E: Exception caught from after_completion synchronization operation: org.hibernate.HibernateException: proxy handle is no longer valid
    	at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.errorIfInvalid(AbstractProxyHandler.java:63)
    	at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:100)
    	at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
    	at $Proxy57.getWrappedObject(Unknown Source)
    	at org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl.close(JdbcResourceRegistryImpl.java:215)
    	at org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl.cleanup(JdbcResourceRegistryImpl.java:189)
    	at org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl.close(JdbcResourceRegistryImpl.java:206)
    	at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.close(LogicalConnectionImpl.java:197)
    	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:141)
    	at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.close(TransactionCoordinatorImpl.java:276)
    	at org.hibernate.internal.SessionImpl.close(SessionImpl.java:334)
    	at org.hibernate.internal.SessionImpl.managedClose(SessionImpl.java:510)
    	at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.afterCompletion(SynchronizationCallbackCoordinatorImpl.java:132)
    	at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.afterCompletion(RegisteredSynchronization.java:61)
    	at org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter$TransactionAdapter$1.invoke(WebSphereExtendedJtaPlatform.java:173)
    	at $Proxy55.afterCompletion(Unknown Source)
    	at com.ibm.ws.jtaextensions.SynchronizationCallbackWrapper.afterCompletion(SynchronizationCallbackWrapper.java:75)
    	at com.ibm.tx.jta.RegisteredSyncs.coreDistributeAfter(RegisteredSyncs.java:357)
    	at com.ibm.ws.tx.jta.RegisteredSyncs.distributeAfter(RegisteredSyncs.java:317)
    	at com.ibm.tx.jta.TransactionImpl.distributeAfter(TransactionImpl.java:2933)
    	at com.ibm.tx.jta.TransactionImpl.postCompletion(TransactionImpl.java:2892)
    	at com.ibm.tx.jta.TransactionImpl.postCompletion(TransactionImpl.java:2805)
    	at com.ibm.tx.jta.TransactionImpl.commitXAResources(TransactionImpl.java:1775)
    	at com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:497)
    	at com.ibm.tx.jta.TransactionImpl.processCommit(TransactionImpl.java:978)
    	at com.ibm.tx.jta.TransactionImpl.commit(TransactionImpl.java:913)
    	at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:369)
    	at com.ibm.tx.jta.TranManagerSet.commit(TranManagerSet.java:161)
    	at com.ibm.ws.uow.UOWManagerImpl.uowCommit(UOWManagerImpl.java:1172)
    	at com.ibm.ws.uow.UOWManagerImpl.uowEnd(UOWManagerImpl.java:1142)
    	at com.ibm.ws.uow.UOWManagerImpl.runUnderNewUOW(UOWManagerImpl.java:1092)
    	at com.ibm.ws.uow.UOWManagerImpl.runUnderUOW(UOWManagerImpl.java:626)
    	at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:281)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:127)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy49.authoriseRequest(Unknown Source)
    Last edited by danielgoodwin; Mar 28th, 2012, 06:16 AM. Reason: Change title

  • #2
    Hi Daniel,
    Did you finaly find an effective configuration with all these versions?
    Thanks

    Comment


    • #3
      The 'only' resolution was to downgrade the Hibernate to version 3. It more or less worked straight away then.
      Sorry cant be of more help.

      Comment


      • #4
        I've no choice, I've to find a solution without downgrading but thanks for the quick answer!

        Comment


        • #5
          Originally posted by theleek View Post
          I've no choice, I've to find a solution without downgrading but thanks for the quick answer!
          what's solution ? Can you help me !

          Comment


          • #6
            Originally posted by theleek View Post
            Hi Daniel,
            Did you finaly find an effective configuration with all these versions?
            Thanks
            My environment is the same as you, I also encountered the same problem, how do you solve the exception Well you? How to solve?

            Comment


            • #7
              My environment is the same as you, I also encountered the same problem, how do you solve the exception Well you? How to solve?

              Comment

              Working...
              X