Skip to content

Using TransactionProxyFactoryBean breaks Spring Batch #4425

Open
@wklaus

Description

@wklaus

Bug description
When a TransactionProxyFactoryBean is configured in a XML-File then the application stops starting with an exception when initializing the datasource because the properties not injected at this time. The Bean is created because Spring tries to find out on wich class is the Annotation EnableBatchProcessing. The error happens only when Spring-Batch-Dependencies in the classpath.

Environment
Spring Batch 3.0.9, Java Version: 17.0.2, H2-Database

Steps to reproduce
Add an XML-File with the configuration of an TransactionProxyFactorBean like the following

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
    <bean id="eineBeanMitTransacton" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager" ref="transactionManagerApp"/>
        <property name="transactionAttributes">
            <props>
                <prop key="*">PROPAGATION_REQUIRES_NEW,timeout_200</prop>
            </props>
        </property>
        <property name="target">
            <bean class="de.wkl.battest.dao.PDaoImpl"/>
        </property>
    </bean>
</beans>

Use this configuration with ImportResource-Annotation

Expected behavior
The Spring-Context should be loaded. With Spring Boot 2.x and Spring Batch 4.x this is not a problem

Minimal Complete Reproducible example
Attached is a minimal example. BattestApplicationTests fails. After removing the ImportResource-Annotation in BatchConfig the Test is green

batchTest.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    has: minimal-exampleBug reports that provide a minimal complete reproducible exampletype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions