2012-05-25 29 views
6

एक साथ समस्या तारों को जारी करना मैं निर्भरता इंजेक्शन को संभालने के लिए वसंत का उपयोग करके एक सैंडबॉक्स बनाने की कोशिश कर रहा हूं। मेरा सैंडबॉक्स कई डोमेन वर्ग है, साथ ही MainClass है, जिसमें main(String[] args) विधि है।वसंत-डेटा-नियो 4j स्टैंडअलोन वसंत परियोजना

व्याख्या में मेरी TestClass@Component साथ और यह सिर्फ उस में

@Autowired 
private Neo4jTemplate neo4jTemplate; 

शामिल हैं।

मेरी main विधि में, मैं अपने applicationContext.xml फ़ाइल है, जो से बना है पर ClassPathXmlApplicationContext फोन:

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

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

लेकिन मेरे कार्यक्रम, यहाँ लाइन पर अमल करने के लिए मैं अपने ClassPathXmlApplicationContext घोषित विफल रहता है एक बड़े पैमाने पर स्टैक ट्रेस के साथ , मैं पहले और आखिरी फेंकने वाले प्रिंट करूंगा।

पहले:

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) 

लास्ट:

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 

मैं neo4j 1.7 और वसंत-डेटा-neo4j 2.0.0.RELEASE, साथ ही वसंत 3.1.0.RELEASE उपयोग कर रहा हूँ।

मुझे वसंत-डेटा-नियो 4j पर उपलब्ध ट्यूटोरियल का उपयोग करके एक अच्छा कारण नहीं मिला है, क्योंकि यह इस अपवाद को क्यों फेंक देगा। क्या कोई मदद कर सकता है?

उत्तर

6

मुझे पता चला कि यह वसंत-डेटा-नियो 4j और neo4j के मिश्रण के साथ एक मुद्दा है जिसका मैं उपयोग कर रहा था।

वसंत-डेटा-neo4j 2.0.1.RELEASE में, Neo4jConfiguration और neo4j 1.8.M01 में, UserTransactionImpl नहीं करता SpringTransactionManager और UserTransactionImpl कि एक AbstractGraphDatabase कक्षा में ले उपयोग करने के लिए कोशिश कर रहा है, और neo4j में 1.7 SpringTransactionManager यह नहीं ले करता है, इसे मत लो।

तो अब के लिए संकल्प neo4j 1.6.2 और वसंत-डेटा-neo4j 2.0.1.RELEASE का उपयोग करना है।

+0

क्या आपके पास कोई खबर है, क्या आप अभी तक अपग्रेड कर सकते हैं? – myborobudur

+0

मैंने थोड़ी देर में चेक नहीं किया है, लेकिन ऐसा लगता है कि वसंत-डेटा-neo4j अभी भी 2.0.1 रिलीज पर है, इसलिए मुझे विश्वास नहीं है कि यह समस्या हल हो गई है। – Nicholas

+1

मुझे एक ही समस्या है, लेकिन मैं वसंत-डेटा-neo4j 2.2.0 का उपयोग कर रहा हूं। कृपया जो मेवेन neo4j 1.8.1 में लाता है। मुझे इसे अलग से घोषित करने की ज़रूरत नहीं है। क्या आप निर्भरता में आकर्षित करने के लिए मेवेन का उपयोग कर रहे हैं? सबसे हालिया रिलीज के साथ कोई भाग्य? – occasl