Hikaricp: Requested bean is currently in creation: Is there an unresolvable circular reference?

Created on 24 Jan 2018  路  4Comments  路  Source: brettwooldridge/HikariCP

I'm trying to implement hikari but I have this error:

/META-INF/datasource.beans.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'dataSource': Requested bean is currently in creation: Is there an unresolvable circular reference?

My config:

<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
    <property name="poolName" value="abc_connection_pool" />
    <property name="dataSourceClassName" value="com.informix.jdbcx.IfxDataSource"/>
    <property name="maximumPoolSize" value="100" />     
    <property name="connectionTimeout" value="500" />
    <property name="validationTimeout" value="300" />
    <property name="maxLifetime" value="30000" />
    <property name="transactionIsolation" value="1" />
    <property name="dataSourceProperties">
    <props>
        <prop key="url">${jdbc.url}</prop>
        <prop key="user">${jdbc.username}</prop>
        <prop key="password">${jdbc.password}</prop>
    </props>
    </property>
</bean>

<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
    <constructor-arg ref="hikariConfig" />
</bean>

Environment

HikariCP version: HikariCP-java6 2.3.13
JDK version     : 1.6
Database        : Informix
Driver version  : Ibm.informix.jdbc 3.00.JC3 

Have you searched the CLOSED issues already? How about checking stackoverflow?

Most helpful comment

I hava this problem too.
I think this is because "public class HikariDataSource extends HikariConfig".
So , I think this is bug.

All 4 comments

@adriandegenhardt A stacktrace would be useful. Is this helpful?

Sorry, This is the stacktrace:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'polizaService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'presupuestoGrandesNominasService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'historicoEstadoPolizaService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityUserDAO' defined in URL [jar:file:/home/tomcat/emi-UAT-ABC/webapps/emi-sis/WEB-INF/lib/foundation-security-0.5.jar!/com/abc/security/dao/SecurityUserDAOImpl.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [jar:file:/home/tomcat/emi-UAT-ABC/webapps/emi-sis/WEB-INF/lib/foundation-persistence-0.5.jar!/META-INF/persistence.beans.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in URL [jar:file:/home/tomcat/emi-UAT-ABC/webapps/emi-sis/WEB-INF/lib/foundation-persistence-0.5.jar!/META-INF/datasource.beans.xml]: Cannot resolve reference to bean 'hikariConfig' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hikariConfig' defined in URL [jar:file:/home/tomcat/emi-UAT-ABC/webapps/emi-sis/WEB-INF/lib/foundation-persistence-0.5.jar!/META-INF/datasource.beans.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'dataSource': Requested bean is currently in creation: Is there an unresolvable circular reference? at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:435) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:409)

@adriandegenhardt According to the internets you cannot use constructor-based injection. You either need to use @AutoWired or property-based injection.

Of course, if you have an actual circular-dependency, that won't help, and you'll have to figure it out.

Either way, I suggesting asking on stackoverflow.com and tagging your question with "Spring".

I hava this problem too.
I think this is because "public class HikariDataSource extends HikariConfig".
So , I think this is bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jobarion picture Jobarion  路  3Comments

ssinganamalla picture ssinganamalla  路  6Comments

coexia picture coexia  路  5Comments

sumeetpri picture sumeetpri  路  3Comments

KaoruDev picture KaoruDev  路  4Comments