Hi all,
I have some problems with Exception Translation when using JtaTransactionManager
this is my spring configuration:
This is my service classCode:<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/> <tx:annotation-driven transaction-manager="transactionManager"/> <context:annotation-config/> <jee:jndi-lookup id="dataSource1" jndi-name="java:comp/env/jdbc/mysql" resource-ref="true"/> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource1" /> <property name="mappingLocations"> <value>classpath*:hbm/*.hbm.xml</value> </property> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.show_sql=true hibernate.transaction.factory_class=org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory hibernate.transaction.jta.platform=org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform hibernate.connection.autocommit=true hibernate.connection.release_mode=auto </value> </property> </bean> <bean id="menuService" class="it.marco.service.impl.MenuServiceImpl" /> <bean id="areaDao" class="it.marco.dao.AreaDaoImpl" /> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
Code:@Transactional public class MenuServiceImpl implements MenuService{ @Autowired private AreaDao areaDao; @Override public void saveOrUpdateArea(DTO<Area> dto) throws DataAccessException { try{ this.areaDao.saveOrUpdate(dto); int i=0; }catch(Throwable daex){ daex.printStackTrace(); } } }
and this is my dao
On the controller that calls the service method I receive aCode:@Repository public class AreaDaoImpl implements AreaDao { @Autowired protected SessionFactory sessionFactory; @Override public void saveOrUpdate(DTO<T> dto) throws DataAccessException { log.debug("DAO saveOrUpdate(DTO<T> dto)"); log.debug("Saving/Update instance of " + this.persistentClass); this.sessionFactory.getCurrentSession().saveOrUpdate(dto.getBusinessObject()); log.debug("SaveOrUpdate succesfull"); } }
org.springframework.transaction.UnexpectedRollback Exception: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
Application Server is JBOSS 7.1.0
I've got the same problems when using EJB3 (in this case I receive a RemoteException)
If I use HibernateTransactionManager as txManager the controller receives a DataAccessException
Can someone help me?
Thanks a lot,
Marco


Reply With Quote