2014-01-07 23 views
0

我想连接本地运行neo4j实例从我的春天的应用程序。 我试图在链接中提到的Twitter应用程序示例工作 sdn-twitter-graph未能连接neo4j服务器从春季应用

,但它与下面的异常失败

` 
Caused by: java.lang.NullPointerException 
    at org.neo4j.rest.graphdb.ExecutingRestRequest.uriWithoutSlash(ExecutingRestRequest.java:78) 
    at org.neo4j.rest.graphdb.ExecutingRestRequest.<init>(ExecutingRestRequest.java:72) 
    at org.neo4j.rest.graphdb.ExecutingRestRequest.with(ExecutingRestRequest.java:149) 
    at org.neo4j.rest.graphdb.entity.RestEntity.<init>(RestEntity.java:52) 
    at org.neo4j.rest.graphdb.entity.RestNode.<init>(RestNode.java:47) 
    at org.neo4j.rest.graphdb.RestAPI.getReferenceNode(RestAPI.java:168) 
    at org.neo4j.rest.graphdb.RestGraphDatabase.getReferenceNode(RestGraphDatabase.java:67) 
    at org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.isAlreadySubRef(TypeRepresentationStrategyFactory.java:71) 
    at org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.chooseStrategy(TypeRepresentationStrategyFactory.java:56) 
    at org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.<init>(TypeRepresentationStrategyFactory.java:40) 
    at org.springframework.data.neo4j.config.Neo4jConfiguration.typeRepresentationStrategyFactory(Neo4jConfiguration.java:151) 
    at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$c7a98d47.CGLIB$typeRepresentationStrategyFactory$9(<generated>) 
    at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$c7a98d47$$FastClassByCGLIB$$d6c07f8a.invoke(<generated>) 
    at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215) 
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:285) 
    at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$c7a98d47.typeRepresentationStrategyFactory(<generated>) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160) 
    ... 82 more 
` 

POM configeration

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.test.spring.neo4j</groupId> 
    <artifactId>TestSpringWithNeo4j</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <dependencies> 
     <dependency> 
      <groupId>org.springframework.data</groupId> 
      <artifactId>spring-data-neo4j</artifactId> 
      <version>2.2.0.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.social</groupId> 
      <artifactId>spring-social-twitter</artifactId> 
      <version>1.0.5.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.neo4j</groupId> 
      <artifactId>neo4j</artifactId> 
      <version>1.8.M06</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-test</artifactId> 
      <version>3.1.0.RELEASE</version> 
     </dependency> 
     <!-- <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> 
      <version>3.0</version> </dependency> --> 
     <dependency> 
      <groupId>org.springframework.data</groupId> 
      <artifactId>spring-data-neo4j-rest</artifactId> 
      <version>2.0.0.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>cglib</groupId> 
      <artifactId>cglib</artifactId> 
      <version>2.2</version> 
     </dependency> 
       <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
      <version>4.1.0.Final</version> 
     </dependency> 
    </dependencies> 
    <repositories> 
     <repository> 
      <id>spring</id> 
      <url>http://repo.springsource.org/libs-milestone</url> 
     </repository> 
     <repository> 
      <id>neo4j</id> 
      <url>http://m2.neo4j.org/content/repositories/releases/org/neo4j/neo4j-cypher-dsl/1.9.M04/</url> 
     </repository> 
    </repositories> 
</project> 

TwitterGraph-server.xml中

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:neo4j="http://www.springframework.org/schema/data/neo4j" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    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.xsd 
     http://www.springframework.org/schema/data/neo4j 
     http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd 
     http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> 

    <context:component-scan base-package="com.test.spring.services"/> 
    <context:annotation-config/> 

    <neo4j:repositories base-package="com.test.spring.repositories"/> 
    <tx:annotation-driven mode="proxy"/> 

    <bean id="graphDatabaseService" 
      class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase"> 
     <constructor-arg value="http://localhost:7474/db/data" /> 
    </bean> 

    <neo4j:config graphDatabaseService="graphDatabaseService"/> 

</beans> 

请帮忙我与配置。

感谢..

+0

你的服务器是什么版本? –

+0

版本是2.0.0 – user3169084

回答

1

你应该再使用的Neo4j 1.8的服务器,为您的SDN的依赖也是1.8。

或等待瞄准Neo4j 2.0的SDN 3.0.M2。

SDN 3.0 M1仍然在2.0.0-M06

+0

谢谢迈克尔.. 解决了这个问题 – user3169084

0

在您的实例的URL的末尾修改斜线:

<bean id="graphDatabaseService" 
     class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase"> 
    <constructor-arg value="http://localhost:7474/db/data/" /> <!-- note slash at the end --> 
</bean> 
+0

不工作已经试过.. :) – user3169084