-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate 5 + Websphere 9
PostPosted: Tue Nov 22, 2016 10:00 am 
Newbie

Joined: Tue Nov 22, 2016 9:01 am
Posts: 3
I'm trying to set up Hibernate 5 to run on Websphere 9. I'm providing the underlying JTA platform via the hibernate.transaction.jta.platform configuration property and setting this to

Code:
<prop key="hibernate.transaction.jta.platform">org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform</prop>


I'm noticing though that WebSphereExtendedJtaPlatform is using a deprecated method in the 9.0 server (registerSynchronizationCallbackForCurrentTran). According to the JTA support site for Websphere 9, you're supposed to use registerInterposedSynchronization method instead. As a possible result of this, I'm having some transaction issues.

So I'm wondering if Hibernate 5 supports Websphere 9 or if this is something that is planned in the future? Or perhaps if someone has experience setting up something similar with Websphere 9?


Top
 Profile  
 
 Post subject: Re: Hibernate 5 + Websphere 9
PostPosted: Tue Nov 22, 2016 4:19 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
I sounds like a bug. Would you mind opening an issue on Jira?

https://hibernate.atlassian.net

Thanks


Top
 Profile  
 
 Post subject: Re: Hibernate 5 + Websphere 9
PostPosted: Wed Nov 23, 2016 6:20 pm 
Newbie

Joined: Tue Nov 22, 2016 9:01 am
Posts: 3
Thanks for the answer. I'm not 100% sure that this is an Hibernate bug and not a configuration problem. I tested the same application with Hibernate 4 on WAS 9, and the transactions and transaction rollbacks worked as expected. I know much has been changed in Hibernate 5 when it comes to the transaction SPI. So it might be possible that the configuration is wrongly set up.

We're using a transaction proxy template with parent/child bean definitions such as this:
Code:
<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
     abstract="true">
   <property name="transactionManager" ref="transactionManager"/>
   <property name="transactionAttributes">
     <props>
       <prop key="*">PROPAGATION_REQUIRED</prop>
     </props>
   </property>
</bean>

<bean id="myProxy" parent="baseTransactionProxy">
   <property name="target" ref="myTarget"/>
</bean>


And the transaction manager and session factory for hibernate 4 is set up with this:

Code:
<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager"/>

<bean id="example.sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
   <property name="dataSource" ref="example.dataSource"/>
   <property name="hibernateProperties">
      <props>
         <prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
         <prop key="hibernate.query.jpaql_strict_compliance">true</prop>
         <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop>
         <prop key="net.sf.ehcache.configurationResourceName">/config-ehcache.xml</prop>
         <prop key="hibernate.cache.use_query_cache">true</prop>
         <prop key="hibernate.cache.use_second_level_cache">true</prop>
         <prop key="hibernate.order_updates">true</prop>                                                     
         <prop key="hibernate.order_inserts">true</prop>                                                       
         <prop key="hibernate.show_sql">false</prop>
         <prop key="hibernate.transaction.factory_class">org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</prop>
         <prop key="hibernate.jdbc.batch_size">50</prop>
         <prop key="hibernate.jdbc.batch_versioned_data">true</prop>                                                           
         <prop key="hibernate.default_batch_fetch_size">50</prop>
         <prop key="hibernate.max_fetch_depth">2</prop>
         <prop key="hibernate.query.substitutions">true '1', false '0'</prop>
         <prop key="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform</prop>
      </props>
   </property>
</bean>


But with Hibernate 5, you're supposed to use the hibernate.transaction.coordinator_class setting:

Code:
<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager"/>

<bean id="example.sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
   <property name="dataSource" ref="example.dataSource"/>
   <property name="hibernateProperties">
      <props>
         <prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
         <prop key="hibernate.query.jpaql_strict_compliance">true</prop>
         <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop>
         <prop key="net.sf.ehcache.configurationResourceName">/config-ehcache.xml</prop>
         <prop key="hibernate.cache.use_query_cache">true</prop>
         <prop key="hibernate.cache.use_second_level_cache">true</prop>
         <prop key="hibernate.order_updates">true</prop>                                                     
         <prop key="hibernate.order_inserts">true</prop>                                                       
         <prop key="hibernate.show_sql">false</prop>
         <prop key="hibernate.jdbc.batch_size">50</prop>
         <prop key="hibernate.jdbc.batch_versioned_data">true</prop>                                                           
         <prop key="hibernate.default_batch_fetch_size">50</prop>
         <prop key="hibernate.max_fetch_depth">2</prop>
         <prop key="hibernate.query.substitutions">true '1', false '0'</prop>
         <prop key="hibernate.id.new_generator_mappings">false</prop>
         <prop key="hibernate.transaction.coordinator_class">jta</prop>
         <prop key="hibernate.transaction.jta.platform">org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform</prop>
      </props>
   </property>
</bean>


Now with Hibernate 5, whenever an exception happens in for example one of the wrapped transaction proxy beans, it does not rollback the transaction completely, but instead seems to commit everything that has happened up to the point of failure.

Is it something wrong with my configuration?


Top
 Profile  
 
 Post subject: Re: Hibernate 5 + Websphere 9
PostPosted: Fri Nov 25, 2016 2:36 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Because you're using WebSphere and JTA, I guess you should use an XA DataSource as well. Does example.dataSource comes from JNDI, and the DS is provided by WebSphere? That should be the case bcause an XA DataSource must be managed by the underlying JTA Transaction Manager, which is WebSphere in your case.


Top
 Profile  
 
 Post subject: Re: Hibernate 5 + Websphere 9
PostPosted: Fri Nov 25, 2016 4:32 am 
Newbie

Joined: Tue Nov 22, 2016 9:01 am
Posts: 3
vlad wrote:
Because you're using WebSphere and JTA, I guess you should use an XA DataSource as well. Does example.dataSource comes from JNDI, and the DS is provided by WebSphere? That should be the case bcause an XA DataSource must be managed by the underlying JTA Transaction Manager, which is WebSphere in your case.


Yes, we do a jndi-lookup for the datasource and the source is provided by WebSphere. The datasource configuration has not been changed and has been tested ok in both Hibernate 3 and 4.


Top
 Profile  
 
 Post subject: Re: Hibernate 5 + Websphere 9
PostPosted: Fri Nov 25, 2016 5:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
From a Hibernate config, it looks good. The problem might be located in Spring Transaction handling. You should also ask the question on their forum as well, or try to dig it and see why the problem happens.


Top
 Profile  
 
 Post subject: Re: Hibernate 5 + Websphere 9
PostPosted: Sat Jan 14, 2017 1:49 am 
Beginner
Beginner

Joined: Wed Jun 15, 2005 1:28 pm
Posts: 39
Location: United States
I wrote a custom platform class to solve this problem. I added this to my persistence.xml file:

Code:
            <property name="hibernate.transaction.jta.platform" value="biz.bitech.hibernate.websphere.WebSphereJtaPlatform"/>


...and this class to a global shared library:

Code:
package biz.bitech.hibernate.websphere;

import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;

import com.ibm.tx.jta.TransactionManagerFactory;
import com.ibm.tx.jta.UserTransactionFactory;
import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform;

public class WebSphereJtaPlatform extends AbstractJtaPlatform {

    @Override
    protected TransactionManager locateTransactionManager() {
        return TransactionManagerFactory.getTransactionManager();
    }

    @Override
    protected UserTransaction locateUserTransaction() {
        return UserTransactionFactory.getUserTransaction();
    }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.