Question

I am trying to connect to a locally installed Neo4j server from the spring boot starter -> gs-accessing-neo4j-data-rest http://spring.io/guides/gs/accessing-neo4j-data-rest/

The server installation is default via Homebrew.

Gradle Build File

buildscript {
repositories {
    maven { url "http://repo.spring.io/libs-milestone" }
    mavenLocal()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.0.RC5")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
    baseName = 'gs-accessing-neo4j-data-rest'
    version = '0.1.0'
}

repositories {
    mavenCentral()
    maven { url "http://repo.spring.io/libs-snapshot" }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.data:spring-data-neo4j:3.0.1.RELEASE")
    compile("org.hibernate:hibernate-validator")
    compile("org.springframework.data:spring-data-rest-webmvc")
    compile("org.springframework.data:spring-data-neo4j-rest:3.0.1.RELEASE") <---ADDED
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}

Application.java

package hello;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.neo4j.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.data.neo4j.rest.SpringRestGraphDatabase;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;

@Configuration
@EnableNeo4jRepositories
@Import(RepositoryRestMvcConfiguration.class)
@EnableAutoConfiguration
public class Application extends Neo4jConfiguration {

    public Application() {
        setBasePackage("hello");
    }

//  @Bean(destroyMethod = "shutdown")
//  public GraphDatabaseService graphDatabaseService() {
//      return new GraphDatabaseFactory().newEmbeddedDatabase("target/hello.db");
//  }

    @Bean
    SpringRestGraphDatabase graphDatabaseService() {
        return new SpringRestGraphDatabase("http://localhost:7474/db/data");
    }   

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Have not made any other changes.

Actual Error:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.HttpMessageConverters org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.messageConverters; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private final java.util.List org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration.converters; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jacksonHttpMessageConverter' defined in class org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.http.converter.json.MappingJackson2HttpMessageConverter org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.jacksonHttpMessageConverter()] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectMapper' defined in class org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public com.fasterxml.jackson.databind.ObjectMapper org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.objectMapper()] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistentEntityJackson2Module' defined in class org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public com.fasterxml.jackson.databind.Module org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.persistentEntityJackson2Module()] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resourceMappings' defined in class org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.rest.core.mapping.ResourceMappings org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.resourceMappings()] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositories' defined in class org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.repository.support.Repositories org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.repositories()] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personRepository': Cannot resolve reference to bean 'neo4jTemplate' while setting bean property 'neo4jTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'application': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.data.neo4j.config.Neo4jConfiguration.setGraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphDataBaseService' defined in class hello.Application: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [org.springframework.data.neo4j.rest.SpringRestGraphDatabase hello.Application.graphDataBaseService()] threw exception; nested exception is java.lang.NoClassDefFoundError: javax/ws/rs/core/Response$StatusType
Was it helpful?

Solution

I had the same issue. It appears that Jersey is required and is not included as a transitive dependency.

compile('com.sun.jersey:jersey-core:1.18.1')

And it works.

OTHER TIPS

Try adding the dependency for neo4j rest:

compile("org.neo4j:neo4j-rest-graphdb:2.0.1")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top