The matching wildcard is strict, but no declaration can be found for element ‘tx:annotation-driven’

You have some errors in your appcontext.xml: Use *-2.5.xsd xsi:schemaLocation=”” Typos in tx:annotation-driven and context:component-scan (. instead of -) <tx:annotation-driven transaction-manager=”transactionManager” /> <context:component-scan base-package=”com.mmycompany” />

Spring Transactions and hibernate.current_session_context_class

When using spring and spring managed transactions never mess around with the hibernate.current_session_context_class property UNLESS you are using JTA. Spring will by default set its own CurrentSessionContext implementation (the SpringSessionContext), however if you set it yourself this will not be the case. Basically breaking proper transaction integration. The only reason for changing this setting is … Read more

Spring @Transactional not working

The reason that moving the context:component-scan tags to the application context xml fixed the transactional behavior is: <tx:annotation-driven /> is a post-processor that wraps @Transactional annotated bean methods with an AOP method interceptor which handles transactional behavior. Spring post-processors, only operate on the specific application context they are defined in. In your case, you have … Read more

Spring – Is it possible to use multiple transaction managers in the same application?

Where you use a @Transactional annotation, you can specify the transaction manager to use by adding an attribute set to a bean name or qualifier. For example, if your application context defines multiple transaction managers with qualifiers: <bean id=”transactionManager1″ class=”org.springframework.orm.jpa.JpaTransactionManager”> <property name=”entityManagerFactory” ref=”entityManagerFactory1″ /> <qualifier value=”account”/> </bean> <bean id=”transactionManager2″ class=”org.springframework.orm.jpa.JpaTransactionManager”> <property name=”entityManagerFactory” ref=”entityManagerFactory2″ /> <qualifier … Read more

Spring + Hibernate manually creating transactions, PROPAGATION_REQUIRED fails. BUG?

You basically don’t use the transaction API as its intended to. The reference documentation is pretty precise about how to use programatic transactions: PlatformTransactionManager manager = … // obtain a transaction manager (DI) TransactionTemplate template = new TransactionTemplate(manager); template.execute(status -> { // Code to be execute in a transaction goes here. }); The important point … Read more