Announcement Announcement Module
No announcement yet.
Issue with circular reference Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issue with circular reference

    Hi -

    I am creating web app with the ability of cross-store persisting data to SQL and No-SQL database. I am using spring-3.1.2, spring-data-neo4j-2.1.0-RC2 and spring-data-jpa-1.1.0.RELEASE.
    Since I am new to neo4j and do not have much experience with Spring, I have started with creating neo4j entities and repositories. I was able to make it working, the data was persisted to graph db - excellent. Bellow is the code of neo4j repositories (looks like the problem may be here):

    public interface CustomDenysEntityRepository {
    	DenysEntity createDenysEntity(DenysEntity de);
    public interface DenysEntityRepository extends CustomDenysEntityRepository,
    		GraphRepository<DenysEntity>, NamedIndexRepository<DenysEntity>{
    public class DenysEntityRepositoryImpl implements CustomDenysEntityRepository {
    	DenysEntityRepository denysEntityRepository;
    	public DenysEntity createDenysEntity(DenysEntity de) {
    		DenysEntity result =;
    		return result;
    My spring-context.xml file is currently not too large:
        <context:component-scan base-package="com.serena.cmdb.denys" />
        <neo4j:config storeDirectory="target/neo4j-db"/>
        <neo4j:repositories base-package="com.serena.cmdb.denys.repository"/>
    As you see I have created the implementation of GraphRepository and NamedIndexRepository with my custom method createDenysEntity. I reused this approach from spring-data-neo4j-reference - everything works fine.

    After that I have started to add spring-data-jpa entities and started to get the following error: Exception in thread "main" org.springframework.beans.factory.BeanCurrentlyInC reationException: Error creating bean with name 'denysEntityRepositoryImpl': Bean with name 'denysEntityRepositoryImpl' has been injected into other beans [denysEntityRepository] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.

    Not sure why do I have this error now? I didn't have it before and was not making changes to neo4j repositories. I was also thinking about some versioning issue, but this is not the case (I believe) because I have created two projects: one of them just with neo4j logic and another one with both neo4j and spring-data-jpa logic (I created the second project just to figure out the reason of the issue that I have). These two projects have identical classpaths, so I think that some new jar files are not the reason of the issue that I have. I see now only one difference: spring-context.xml. Now it looks as follows:

        <context:spring-configured />
        <context:annotation-config />
        <context:component-scan base-package="com.serena.resourcemgmt" />
        <jpa:repositories base-package="com.serena.resourcemgmt.repositories" />
        <neo4j:config storeDirectory="resourcemgmt-neo4j-db-test" entityManagerFactory="entityManagerFactory"/>
        <neo4j:repositories base-package="com.serena.resourcemgmt.repositories"/>
        <tx:annotation-driven transaction-manager="transactionManager" />
        <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    	<property name="location" value="" />
        <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="persistenceUnitName" value="spring-jpa" />
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                    <property name="showSql" value="${hibernate.show_sql}" />
                    <property name="generateDdl" value="${hibernate.generate_ddl}" />
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    	<property name="driverClassName" value="${db.driver}" />
    	<property name="url" value="${db.url}" />
    	<property name="username" value="${db.username}" />
    	<property name="password" value="${db.password}" />
    Not sure what is the problem and do not know how to fix it, three days spent with no result... Please help!

    Thanks in advance,