I can't get @Transactional annotation to work with xml-defined bean. I don't know if xml definition has anything to do with it. Maybe it's the issue with OSGi.
<bean id="myDao"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="txManager"/>
<property name="target" ref="myDao_t"/>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_MANDATORY,
timeout_60,
-Exception
</prop>
</props>
</property>
</bean>
When I specify a proxy with xml like above it works.
I have <tx:annotation-driven transaction-manager="txManager" />
specified in the same bundle-context.xml where the bean definition is.
MyDao is just a simple class implementing interface with one method.
There is no exception, it just doesn't create proxy for myDao.
What might be missing?
<bean id="myPlanner" class="com.something.planner.MyPlanner">
<property name="myDao" ref="myDao" />
</bean>
Try this:
myDao
should beMyDao
(the type of the DAO instead ofTransactionProxyFactoryBean
).@Transactional
on each public method inMyDao.java
.Spring should then automatically create a proxy for you. The approach in your question looks like "I try to create and configure the proxy factory myself".
While there surely is away to do that, I don't know exactly how you would do that. Instead, I rely on
<tx:annotation-driven>
and the@Transactional
annotation.EDIT You're using Spring 2.5.6A.
I just checked and
@Transactional
was added with Spring 1.2. But I'm not sure when<tx:annotation-driven>
was added. The relatedEnableTransactionManagement
was added with 3.1.But the XML element is in this schema: http://www.springframework.org/schema/tx/spring-tx-2.5.xsd so it should be available in 2.5.
Maybe you're missing the necessary AOP libraries (cglib) on the classpath?