7

Many are claiming that the SDN version 3.3.1 or 4.0.0.RC1 should work with neo4j 2.2.x but I could not make it to work.

I have this spring config configuration:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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:neo4j="http://www.springframework.org/schema/data/neo4j"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <context:annotation-config />
    <context:spring-configured />

    <neo4j:config graphDatabaseService="graphDatabaseService" base-package="com.x.protogy.neo4j"/>
    <bean id="graphDatabaseService"
        class="org.springframework.data.neo4j.rest.SpringCypherRestGraphDatabase">
      <constructor-arg index="0" value="http://localhost:7476/db/data" />
    </bean>
    <tx:annotation-driven mode="aspectj"
        transaction-manager="transactionManager" />

</beans>

That generates this exception:

Caused by: java.lang.ClassNotFoundException: org.neo4j.kernel.impl.nioneo.store.StoreId
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)

Looking in the code makes it clear: SDN refers to a class in neo4j library that was eliminated in 2.2.x:

org.neo4j.kernel.impl.nioneo.store.StoreId

What are my options in this case?

biliboc
  • 737
  • 1
  • 10
  • 25

3 Answers3

7

Try this Java configuration file instead of XML configuration.

import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;


@Configuration
@EnableNeo4jRepositories("com.app.repository")
@EnableTransactionManagement
@ComponentScan("com.app")

public class AppNeo4jConfiguration extends Neo4jConfiguration{


    public SessionFactory getSessionFactory() {
        return new SessionFactory("com.app.bo");
    }


    @Bean
    public Neo4jServer neo4jServer() {
        return new RemoteServer("http://localhost:7474");
    }


    @Bean
    @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
    public Session getSession() throws Exception {
        return super.getSession();
    }
}
jscs
  • 63,694
  • 13
  • 151
  • 195
Kunal Kumar
  • 1,722
  • 1
  • 17
  • 32
1

I can answer specifically for SDN 4 (4.0.0.RC1) - that it definitely works with Neo4j 2.2

XML configuration isn't supported so you'll need to use Java based configuration. See http://docs.spring.io/spring-data/neo4j/docs/4.0.0.RC1/reference/html/#reference_setup

Also a short guide https://www.airpair.com/neo4j/posts/the-essence-of-spring-data-neo4j-4

and example applications https://github.com/neo4j-examples?query=sdn4

Luanne
  • 19,145
  • 1
  • 39
  • 51
1

I also had some problems with getting SDN to work with new Neo4j: Cannot configure @Transaction to work with Spring Data Neo4j

(BTW. there is a Java configuration that worked for me, maybe try it out when moving from XML to Java ...)

It was probably also caused by missing class from neo4j-kernel jar... Managed to find a workaround after debugging and investigating source code, but maybe the best idea for now is to downgrade neo4j version ...

Community
  • 1
  • 1
cichystefan
  • 328
  • 2
  • 10
  • Getting close but I'm not using the embedded server but the rest endpoint server. I think that either I'm still missing something or the new SDN is made to work only when the server is embedded. – biliboc Jul 28 '15 at 05:45