Repository navigation
Closed
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
Milestone
Description
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:
- stack-overflow-error.jar (3.54 kB)
Issue Links:
- FactoryBean bean type detection can causes fatal early instantiation [SPR-11202] #15828 FactoryBean bean type detection can causes fatal early instantiation
- Plain FactoryBean declaration on @Bean method leads to early call (pre injection) [SPR-12141] #16755 Plain FactoryBean declaration on
@Beanmethod leads to early call (pre injection) - findDefaultEntityManagerFactory should consider EMF bean's primary flag [SPR-7549] #12206 findDefaultEntityManagerFactory should consider EMF bean's primary flag
- HttpInvokerProxyFactoryBean and co do not reliably expose correct type when declared via @Bean [SPR-11842] #16461 HttpInvokerProxyFactoryBean and co do not reliably expose correct type when declared via
@Bean - Modification in AbstractAutowireCapableBeanFactory to prevent stackoverflow errors causes context not to load. [SPR-15125] #19692 Modification in AbstractAutowireCapableBeanFactory to prevent stackoverflow errors causes context not to load.
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
Activity
spring-projects-issues commentedon Aug 1, 2016
Victor Bronstein commented
I didn't know what components to specify because it is not clear where the bug is. Sorry about that!
In the attached project there are comments in the context XML indicating the lines that when commented out, make StackOverflowError go away. I couldn't understand why the presence of these lines causes the issue to appear.
spring-projects-issues commentedon Aug 11, 2016
Victor Bronstein commented
Did you manage to reproduce the issue? Is there something I can help with?
spring-projects-issues commentedon Aug 11, 2016
Juergen Hoeller commented
It turns out that this was a case not caught by our currently-in-creation checks, only kicking in for a chain of
factory-beanreferences that end up pointing to aFactoryBeanimplementation class. Fixed for 4.3.3 now, and to be backported to 4.2.8 and 3.2.18.spring-projects-issues commentedon Aug 12, 2016
Stéphane Nicoll commented
Tested the sample project with
4.3.3.BUILD-SNAPSHOT. Works fine now.