Here is the scenario…unit tests of address book sample work and pass thwroing the ContactnameAlreadyTaken Exception. the challenge is that with transaction management and JPA when dispatching command on command bus cannot get back the BusinessDomain exception handling but instead gets the JPA exception, even though the command handler throws the business exception as in the address-book sample code. Snippet of trace showing JPA Exception instead of desired ContactNameAlreadyTakenException with the CommandCallBack on failure throwable cause parameter…Any ideas or suggestions on what could be going wrong… Below is snippet of stack trace illustrating the issue.
2011-05-17 23:47:26,345 [SimpleAsyncTaskExecutor-2] WARN com.addressbook.server.domain.contact.commandhandler.JpaContactNameRepository - Unable to claim contact Name. Contact with name already exists
2011-05-17 23:47:26,346 [SimpleAsyncTaskExecutor-2] ERROR com. addressbook.server.seviceCallingCommandViaCommandBus - Contact seems to be existing with cause - org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly
org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:476)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy38.claimContactName(Unknown Source)
at com.addressbook.server.domain.contact.commandhandler.ContactCommandHandler.handle(ContactCommandHandler.java:50)