Announcement Announcement Module
Collapse
No announcement yet.
Spring data neo4j error on start: Singleton 'xxx' isn't currently in creation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring data neo4j error on start: Singleton 'xxx' isn't currently in creation

    Hi there! I'm trying to get the neo4j integration working with my current project. But I'm getting an error:

    DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating shared instance of singleton bean 'datasource'
    DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating instance of bean 'datasource'
    DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'appConfig'
    DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating shared instance of singleton bean 'datasource'
    DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating instance of bean 'datasource'
    DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'appConfig'
    DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating shared instance of singleton bean 'datasource'
    DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating instance of bean 'datasource'

    That repeats for hundreds of lines and finally:

    ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'initializer': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: javax.sql.DataSource com.fb.tweepology.config.Initializer.datasource; nested exception is java.lang.IllegalStateException: Singleton 'datasource' isn't currently in creation
    at org.springframework.beans.factory.annotation.Autow iredAnnotationBeanPostProcessor.postProcessPropert yValues(AutowiredAnnotationBeanPostProcessor.java: 287)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 95)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:225)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:292 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:464)
    at org.springframework.web.context.ContextLoader.conf igureAndRefreshWebApplicationContext(ContextLoader .java:377)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:278)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 111)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:4544)
    at org.apache.catalina.core.StandardContext.startInte rnal(StandardContext.java:5016)
    at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:140)
    at org.apache.catalina.core.ContainerBase.startIntern al(ContainerBase.java:1035)
    at org.apache.catalina.core.StandardHost.startInterna l(StandardHost.java:738)
    at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:140)
    at org.apache.catalina.core.ContainerBase.startIntern al(ContainerBase.java:1035)
    at org.apache.catalina.core.StandardEngine.startInter nal(StandardEngine.java:289)
    at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:140)
    at org.apache.catalina.core.StandardService.startInte rnal(StandardService.java:442)
    at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:140)
    at org.apache.catalina.core.StandardServer.startInter nal(StandardServer.java:674)
    at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:140)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:596)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:303)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:431)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: javax.sql.DataSource com.fb.tweepology.config.Initializer.datasource; nested exception is java.lang.IllegalStateException: Singleton 'datasource' isn't currently in creation
    at org.springframework.beans.factory.annotation.Autow iredAnnotationBeanPostProcessor$AutowiredFieldElem ent.inject(AutowiredAnnotationBeanPostProcessor.ja va:504)
    at org.springframework.beans.factory.annotation.Injec tionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.Autow iredAnnotationBeanPostProcessor.postProcessPropert yValues(AutowiredAnnotationBeanPostProcessor.java: 284)
    ... 33 more
    Caused by: java.lang.IllegalStateException: Singleton 'datasource' isn't currently in creation
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.afterSingletonCreation(Defaul tSingletonBeanRegistry.java:312)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:239)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:292 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.findAutowireCandidates(DefaultL istableBeanFactory.java:844)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.doResolveDependency(DefaultList ableBeanFactory.java:786)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.resolveDependency(DefaultListab leBeanFactory.java:703)
    at org.springframework.beans.factory.annotation.Autow iredAnnotationBeanPostProcessor$AutowiredFieldElem ent.inject(AutowiredAnnotationBeanPostProcessor.ja va:476)
    ... 35 more

    I'm using Spring 3.1.0.M2, I don't know if it would be compatible with spring-data-neo4j.

    Here's the configuration that bootstrap my application context:

    Code:
    @Configuration
    @ComponentScan(basePackages = "com.fb.tweepology", excludeFilters = { @Filter(Configuration.class) })
    @PropertySource("classpath:com/fb/tweepology/config/application.properties")
    @EnableTransactionManagement(mode=AdviceMode.ASPECTJ)
    @ImportResource("classpath:com/fb/tweepology/config/datagraph.xml")
    public class AppConfig {
    
    	
    	@Inject
    	private Environment environment;
    	
    	
    	@Bean
    	public PlatformTransactionManager transactionManager() {
    		return new DataSourceTransactionManager(datasource());
    	}
    	
    	
    	@Bean
    	public JdbcTemplate jdbcTemplate() {
    		return new JdbcTemplate(datasource());
    	}
    
    	
    	@Bean(destroyMethod="close")
    	public DataSource datasource(){
    		BasicDataSource ds = new BasicDataSource();
    		ds.setDriverClassName(environment.getProperty("db.driver"));
    		ds.setUrl(environment.getProperty("db.url"));
    		ds.setUsername(environment.getProperty("db.username"));
    		ds.setPassword(environment.getProperty("db.password"));
    		return ds;
    	}
    	
    	
    }
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:datagraph="http://www.springframework.org/schema/data/graph"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/data/graph http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd
            ">
        <datagraph:config storeDirectory="target/config-tests"/>
    </beans>
    If I remove the datagraph part, it works fine.

    Just need some advice on this. I'm going to move to 3.0.5 without the @Configuration and see if works, but in meantime any suggestion would be most appreciated.

    Regards

  • #2
    Haven't tried it with 3.1.0.M2, you probably have to exclude the 3.0.5 depencendies from spring-data-graph, could you look at mvn dependency:tree ?

    If that is not the cause, could you provide a simple test project that exhibits that behaviour, so that I could examine it?

    Thanks so much

    Michael

    Comment


    • #3
      Does anyone have any further input on this thread? I'm encountering the same issue w/ Spring 3.1.0.RC1.

      Comment


      • #4
        I've confirmed that this behavior isn't exhibited with Spring 3.0.5.RELEASE.

        It would seem there is an incompatibility between Spring 3.1.0.x and Spring Datagraph. :-/

        I'll keep digging deeper (so I can file a well-informed issue in Jira), but in the meantime, I'm hoping someone from SpringSource might take note of this thread.

        Comment


        • #5
          I used the hello-worlds example. Excluding all spring dependencies from the spring-data-neo4j(-aspects) depenency and adding them again with 3.1.0.RC1.

          I tried to figure out what went wrong. I simplified the configuration so that this error no longer occurs.

          Now I'm getting one regarding "conversionService", which is "not in creation". Or if I put @Scope("prototype") on that I get an error that says it is "in creation".

          Really weird. Will continue to look into this.

          I pushed a remote branch named 310 that contains that.
          Last edited by MichaelHunger; Oct 18th, 2011, 09:17 PM.

          Comment


          • #6
            I've also been testing with minimal configuration and conversionService is precisely the bean that is giving me trouble. Good to know we're both seeing the same issue.

            Comment


            • #7
              I'm having a helluva time isolating the issue, but I've determined that it was introduced with a change between Spring 3.1.0.M1 (which works fine) and Spring 3.1.0.M2 (which does not).

              This may narrow it down a little bit.

              Comment


              • #8
                Some more insight...

                The following seems to work fine:

                Code:
                ApplicationContext appContext = new ClassPathXmlApplicationContext("/com/foo/core/daos/UserRepositoryIntegrationTest-context.xml");
                Whilst this does not:

                Code:
                @RunWith(SpringJUnit4ClassRunner.class)
                @ContextConfiguration
                public class UserRepositoryIntegrationTest {
                
                    // ...
                
                }
                This would seem to indicate the offending change resides somewhere within spring-test.

                Per release notes here, 3.1.0.M2 included the following change:

                • TestContext framework support for @Configuration classes and bean definition profiles

                Comment


                • #9
                  Thanks for the analysis, guys. We are indeed looking into this. Watch https://jira.springsource.org/browse/SPR-8824 to be notified of the fix.

                  Comment


                  • #10
                    Resolved. Please see the resolution comments on the issue linked above, and test against the next nightly snapshot build. Thanks!

                    Comment

                    Working...
                    X