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:
If I remove the datagraph part, it works fine.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>
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


Reply With Quote