2012-05-25 8 views
6

Próbuję utworzyć sandbox za pomocą sprężyny do obsługi iniekcji zależności. Moja piaskownica to kilka klas domeny, a także MainClass, która zawiera w sobie metodę main(String[] args).Wydanie okablowania razem Spring-data-neo4j samodzielny projekt wiosny

W adnotacji mój TestClass z @Component i to właśnie zawiera

@Autowired 
private Neo4jTemplate neo4jTemplate; 

w nim.

W mojej metody main wzywam ClassPathXmlApplicationContext na moim pliku applicationContext.xml, który składa się z:

<context:annotation-config/> 
<context:spring-configured/> 
<context:component-scan base-package="org.neuralsandbox"/> 

<neo4j:config storeDirectory="data/sandbox.db"/> 

ale mój program nie wykona na linii tutaj Deklaruję ClassPathXmlApplicationContext, z masywnym ślad stosu , Wydrukuję pierwszy i ostatni throwables.

pierwsze:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testClass': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.data.neo4j.support.Neo4jTemplate org.neuralsandbox.TestClass.neo4jTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTemplate' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public final org.springframework.data.neo4j.support.Neo4jTemplate org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$a3874640.neo4jTemplate() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingInfrastructure' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public final org.springframework.data.neo4j.support.MappingInfrastructure org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$a3874640.mappingInfrastructure() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTransactionManager' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public final org.springframework.transaction.PlatformTransactionManager org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$a3874640.neo4jTransactionManager()] threw exception; nested exception is java.lang.NoSuchMethodError: org.neo4j.kernel.impl.transaction.UserTransactionImpl.<init>(Lorg/neo4j/graphdb/GraphDatabaseService;)V 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1073) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:516) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) 
    at org.neuralsandbox.MainClass.main(MainClass.java:8) 

Ostatnio:

Caused by: java.lang.NoSuchMethodError: org.neo4j.kernel.impl.transaction.UserTransactionImpl.<init>(Lorg/neo4j/graphdb/GraphDatabaseService;)V 
    at org.springframework.data.neo4j.config.Neo4jConfiguration.createJtaTransactionManager(Neo4jConfiguration.java:240) 
    at org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTransactionManager(Neo4jConfiguration.java:232) 
    at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$a3874640.CGLIB$neo4jTransactionManager$21(<generated>) 
    at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$a3874640$$FastClassByCGLIB$$ed4fda1e.invoke(<generated>) 
    at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) 
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:210) 
    at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$a3874640.neo4jTransactionManager(<generated>) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:145) 
    ... 72 more 

Używam neo4j 1,7 i wiosna-data-neo4j 2.0.0.RELEASE, jak również sprężyny 3.1.0.RELEASE.

Nie znalazłem dobrego powodu, korzystając z samouczków dostarczonych na wiosnę-dane-neo4j, dlaczego miałoby to rzucić ten wyjątek. Czy ktoś może pomóc?

Odpowiedz

6

Stwierdziłem, że jest to problem związany z mieszanką danych sprężynowych - neo4j i neo4j, z których korzystałem.

W wiosenno-data-neo4j 2.0.1.RELEASE, Neo4jConfiguration próbuje użyć SpringTransactionManager i UserTransactionImpl które odbywają się w klasie AbstractGraphDatabase, aw neo4j 1,7 SpringTransactionManager nie bierze go, aw neo4j 1.8.M01, UserTransactionImpl nie robi nie bierz tego.

Tak więc na razie rozdzielczość jest taka, aby używać neo4j 1.6.2 i danych źródłowych-neo4j 2.0.1.RELEASE.

+0

Czy masz jakieś nowości, czy możesz je teraz uaktualnić? – myborobudur

+0

Nie sprawdzałem od jakiegoś czasu, ale wygląda na to, że dane wiosenne - neo4j wciąż jest w wersji 2.0.1, więc nie sądzę, aby problem został rozwiązany. – Nicholas

+1

Mam dokładnie ten sam problem, ale używam danych źródłowych-neo4j 2.2.0.Release, które Maven przynosi w neo4j 1.8.1. Nie muszę tego deklarować osobno. Czy korzystasz z Mavena, aby narysować zależności? Masz szczęście w najnowszym wydaniu? – occasl