Skip to content

StackOverflowError for advisor search against factory-bean reference to FactoryBean [SPR-14551] #19119

Closed
@spring-projects-issues

Description

@spring-projects-issues

Victor Bronstein opened SPR-14551 and commented

StackOverflowError happens when powering up an application context that includes JPA Hibernate entity manager, defines tx:annotation-driven/ and Hibernate statistics bean.
The minimal project reproducing the issue is attached. Here's the snippet of the XML:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!-- Comment this line to make the test pass -->
    <tx:annotation-driven/>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="packagesToScan" value="com.mycompany.*"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect"/>
            </bean>
        </property>
    </bean>

    <bean name="dataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
        <property name="driverClassName" value="org.h2.Driver"/>
        <property name="url" value="jdbc:h2:mem:test"/>
        <property name="username" value="sa"/>
    </bean>

    <bean id="sessionFactory" factory-bean="entityManagerFactory" factory-method="getSessionFactory" scope="prototype"/>
    <!-- Or comment this line to make the test pass -->
    <bean id="hibernateStatistics" factory-bean="sessionFactory" factory-method="getStatistics" scope="prototype"/>

</beans>

Affects: 3.2.17, 4.1.9, 4.2.7, 4.3.2

Attachments:

Issue Links:

Backported to: 4.2.8, 3.2.18

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions