AnsweredAssumed Answered

Spring Transactions

Question asked by amdonov on May 1, 2008
We're having trouble with rollbacks that are similar to the ones described in AR-2059.  In an effort to rule out improper handling of rollbacks on our part, we would like to let Spring manage our transactions.  Based upon information in the wiki this is supported, but we have been unable to find any working examples.  Has anyone attempted this?  Ideally we'd like to add the @Transactional annotation to our classes and have public operations wrapped in transactions that rollback on RuntimeExceptions.  We've run into problems that are apparently related to auto-proxying.  We get errors like the following
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'avmLockingBootstrap' defined in class path resource [alfresco/bootstrap-context.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy44] to required type [org.alfresco.repo.avm.locking.AVMLockingServiceImpl] for property 'avmLockingService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy44] to required type [org.alfresco.repo.avm.locking.AVMLockingServiceImpl] for property 'avmLockingService': no matching editors or conversion strategy found
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy44] to required type [org.alfresco.repo.avm.locking.AVMLockingServiceImpl] for property 'avmLockingService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy44] to required type [org.alfresco.repo.avm.locking.AVMLockingServiceImpl] for property 'avmLockingService': no matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy44] to required type [org.alfresco.repo.avm.locking.AVMLockingServiceImpl] for property 'avmLockingService': no matching editors or conversion strategy found
   at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
   at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
   at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:815)
   at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
   at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
   at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1126)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:247)
   at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:796)
   at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:592)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
   at net.provideal.es.test.ManualTestRunner.main(ManualTestRunner.java:37)

Outcomes