Reputation: 3259
My WebSphere 8 driven portlet uses Spring 4 and Hibernate 4.3 over JPA. I have a JTA data source. This is my setup:
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
>
<persistence-unit name="myUnit" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/mydb</jta-data-source>
<properties>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform" />
<property name="hibernate.transaction.factory_class" value="org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory" />
<property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect" />
</properties>
</persistence-unit>
</persistence>
my-portlet.xml
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="myUnit" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.DB2Dialect" />
<property name="showSql" value="true" />
</bean>
</property>
</bean>
When my DAO-method is called, an exceptions are thrown:
00000090 RegisteredSyn E WTRN0074E: Exception caught from before_completion synchronization operation: java.lang.IncompatibleClassChangeError
at com.ibm.ws.uow.ComponentContextSynchronizationWrapper.beforeCompletion(ComponentContextSynchronizationWrapper.java:65)
and
(... servlet and portlet specific exceptions ...)
Caused by: org.springframework.transaction.TransactionSystemException: UOWManager transaction processing failed; nested exception is com.ibm.wsspi.uow.UOWException: javax.transaction.RollbackException
(...)
Caused by: java.lang.IncompatibleClassChangeError
This is my DAO-class:
@Repository("myDao")
@SuppressWarnings("unchecked")
public class HibernateMyEntityDao implements MyEntityDao
{
@PersistenceContext(unitName = "myUnit")
private EntityManager entityManager;
public Session getSession()
{
return entityManager.unwrap(Session.class);
}
@Transactional
public List<MyEntity> findActive()
{
Calendar date = Calendar.getInstance();
Criteria crit = getSession().createCriteria(MyEntity.class);
crit.setFirstResult(0);
crit.setFetchSize(10);
crit.add(Restrictions.le("start", date));
crit.add(Restrictions.gt("end", date));
return crit.list();
}
}
What am I doing wrong here?
Upvotes: 0
Views: 2219
Reputation: 3191
A IncompatibleClassChangeError
normally indicates that the dependency versions are incorrect. You can read more about it here and here.
It is probable that the combination of websphere 8, spring 4 and hibernate 4.3 are not compatible with each other. My guess is on hibernate 4.3 and websphere 8 not being compatible. Did you try with slightly older versions of spring and hibernate?
Upvotes: 1