Back Forum Reply New

Glassfish v3.0.1 / JTA / (JPA2/Hibernate3.5) / Spring 3 exception mapping.

EXCEPTION TRANSLATION NOT WORKING FOR PERSISTENCE WITH GLASSFISH JTA.

Could someone help, please? Spring-certified Professional here CLUELESS - getting org..transaction.UnexpectedRollback  Exception instead of org..dao.DataIntegrityViolationExce  ption because I cannot find how to configure Glassfish JTA to work with Spring exception translation capabilities. Here's my new config:

jta-glassfish.xml:Code:

lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;

lt;beans xmlns=quot;schema/beansquot;
xmlns:tx=quot;schema/txquot; xmlns:aop=quot;schema/aopquot;
xmlns:amq=quot;schema/corequot; xmlns:jms=quot;schema/jmsquot;
xmlns:xsi=quot;2001/XMLSchema-instancequot; xmlns:context=quot;schema/contextquot;
xmlns:jee=quot;schema/jeequot;
xsi:schemaLocation=quot;
schema/context
schema/context/spring-context-3.0.xsd
schema/beans
schema/beans/spring-beans-3.0.xsd
schema/tx
schema/tx/spring-tx-3.0.xsd
schema/aop
schema/aop/spring-aop-3.0.xsd  
schema/core schema/core/activemq-core-5.3.2.xsd  
schema/jms schema/jms/spring-jms-3.0.xsd
schema/jee schema/jee/spring-jee-3.0.xsdquot;gt;

lt;!-- database connection pools --gt;

lt;!-- lt;jee:jndi-lookup id=quot;dataSourcequot; jndi-name=quot;jdbc/postgresXAquot; /gt; --gt;

lt;bean
class=quot;org..orm.jpa.support.PersistenceAnnotationBeanPostProcessorquot;gt;
lt;property name=quot;persistenceUnitsquot;gt;
lt;mapgt;
lt;entry key=quot;tasktidequot; value=quot;persistence/tasktidequot; /gt;

lt;/mapgt;
lt;/propertygt;
lt;property name=quot;defaultPersistenceUnitNamequot; value=quot;tasktidequot; /gt;
lt;/beangt;
lt;!-- lt;jee:jndi-lookup id=quot;entityManagerFactoryquot; jndi-name=quot;persistence/tasktidequot;
/gt; --gt;

lt;bean id=quot;entityManagerFactoryquot;
class=quot;org..orm.jpa.LocalContainerEntityManagerFactoryBeanquot;gt;
lt;property name=quot;persistenceUnitNamequot; value=quot;tasktidequot; /gt;
lt;property name=quot;jpaVendorAdapterquot;gt;
lt;bean class=quot;org..orm.jpa.vendor.HibernateJpaVendorAdapterquot;gt;
lt;property name=quot;showSqlquot; value=quot;truequot; /gt;
lt;property name=quot;databasequot; value=quotOSTGRESQLquot; /gt;
lt;/beangt;
lt;/propertygt;

lt;property name=quot;jpaPropertiesquot;gt;
lt;propsgt;
lt;prop key=quot;hibernate.transaction.manager_lookup_classquot;gt;org.hibernate.transaction.SunONETransactionManagerLookup
lt;/propgt;

lt;/propsgt;
lt;/propertygt;

lt;/beangt;lt;!-- jms connections --gt;

lt;jee:jndi-lookup id=quot;jmsConnectionFactoryquot; jndi-name=quot;jms/activemqquot; /gt;

lt;jee:jndi-lookup id=quot;emailNowQueuequot; jndi-name=quot;jms/emailnowquot; /gt;
lt;jee:jndi-lookup id=quot;emailRegQueuequot; jndi-name=quot;jms/emailregquot; /gt;
lt;jee:jndi-lookup id=quot;matchNowQueuequot; jndi-name=quot;jms/matchnowquot; /gt;
lt;jee:jndi-lookup id=quot;matchRegQueuequot; jndi-name=quot;jms/matchregquot; /gt;
lt;jee:jndi-lookup id=quot;statQueuequot; jndi-name=quot;jms/statquot; /gt;

lt;bean id=quot;jmsTemplatequot; class=quot;org..jms.core.JmsTemplatequot;gt;
lt;property name=quot;connectionFactoryquot;gt;
lt;ref bean=quot;jmsConnectionFactoryquot; /gt;
lt;/propertygt;
lt;property name=quot;defaultDestinationquot;gt;
lt;ref bean=quot;emailRegQueuequot; /gt;
lt;/propertygt;
lt;property name=quot;receiveTimeoutquot; value=quot;1000quot; /gt;
lt;property name=quot;sessionTransactedquot; value=quot;truequot; /gt;
lt;/beangt;

lt;!-- transaction manager --gt;

lt;tx:annotation-driven /gt;

lt;bean id=quot;transactionManagerquot; class=quot;org..transaction.jta.JtaTransactionManagerquot;/gt;

lt;!-- lt;tx:jta-transaction-manager /gt; --gt;

lt;bean class=quot;org..dao.annotation.PersistenceExceptionTranslationPostProcessorquot;/gt;

lt;bean id=quot;jpaDialectquot; class=quot;org..orm.jpa.vendor.HibernateJpaDialectquot;
autowire-candidate=quot;falsequot; /gt;

lt;/beansgt;

lt;/beansgt;
persistence.xml:Code:

lt;persistence xmlns=quot;xml/ns/persistencequot;
xmlns:xsi=quot;2001/XMLSchema-instancequot;
xmlns:schemaLocation=quot;xml/ns/persistence xml/ns/persistence/persistence_1_0.xsdquot;
version=quot;1.0quot;gt;

lt;persistence-unit name=quot;tasktidequot; transaction-type=quot;JTAquot;gt; lt;!-- JTA, RESOURCE_LOCAL --gt;
lt;jta-data-sourcegt;jdbc/postgresXAlt;/jta-data-sourcegt;

lt;providergt;org.hibernate.ejb.HibernatePersistencelt;/providergt;
lt;propertiesgt;lt;!-- enable this if org.hibernate.dialect.PostgreSQLDialect does not work
lt;property name=quot;hibernate.dialectquot; value=quot;net.sf.hibernate.dialect.PostgreSQLDialectquot;
/gt; --gt;

lt;property name=quot;hibernate.dialectquot; value=quot;org.hibernate.dialect.PostgreSQLDialectquot; /gt;

lt;!-- enable this for atomikos jta lt;property name=quot;hibernate.transaction.manager_lookup_classquot;
value=quot;com.atomikos.icatch.jta.hibernate3.TransactionManagerLookupquot; /gt; --gt;

lt;!--
lt;property name=quot;hibernate.transaction.manager_lookup_classquot; value=quot;org.hibernate.transaction.SunONETransactionManagerLookupquot;
/gt;--gt;
lt;!-- lt;property name=quot;hibernate.transaction.factory_classquot; value=quot;com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactoryquot;/gt; --gt;

lt;property name=quot;hibernate.cache.provider_classquot;
value=quot;org.hibernate.cache.SingletonEhCacheProviderquot; /gt;

lt;property name=quot;hibernate.cache.provider_configurationquot;
value=quot;../ehcache.xmlquot; /gt;

lt;property name=quot;hibernate.cache.provider_configuration_file_resource_pathquot;
value=quot;../ehcache.xmlquot; /gt;

lt;property name=quot;hibernate.cache.use_second_level_cachequot;
value=quot;truequot; /gt;

lt;property name=quot;hibernate.cache.use_query_cachequot; value=quot;truequot; /gt;
lt;/propertiesgt;
lt;/persistence-unitgt;
lt;/persistencegt;
It works fine, but produces UnexpectedRollbackException with a wrapped javax.transaction.RollbackException, instead of providing me with an unchecked org..dao.* exception translation.

Can it even be done?

P.S. I placed all the jars (including jpa, jms, etc.) into the glassfishv3/domains/domain1/lib directory.

P.P.S. Glassfish definitely sees the exceptions:

WARNING: JTS5033: Exception [javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationExcepti  on: Could not execute JDBC batch update] on [before_completion] synchronization operation.

But it never gets seen by my code, instead I get the javax.transaction.RollbackException.

Could someone please advise me what I am doing wrong?

Anyone on thi forum got a clue? Marten?
¥
Back Forum Reply New