Question

i am trying to connect locally running neo4j instance from my spring application. i am trying to work with the twitter application example mentioned in link sdn-twitter-graph

but it is failing with below exception

`
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>

please help me with the configuration.

thanks..

Was it helpful?

Solution

You should then use Neo4j 1.8 as server, as your SDN dependency is also for 1.8.

Or wait for SDN 3.0.M2 which is targeting Neo4j 2.0.

SDN 3.0 M1 is still at 2.0.0-M06

OTHER TIPS

Amend a slash at the end of the URL of your instance:

<bean id="graphDatabaseService"
      class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
     <constructor-arg value="http://localhost:7474/db/data/" />  <!-- note slash at the end -->
</bean>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top