1
votes

I'm trying to "upgrade" my appplicaition from using an embedded neo4j database to use a server based setup.

I'm using spring as the framework for setting up easy repositories and it works like a charm.

Now I'm trying to include a dependency for org.springframework.data:spring-data-neo4j so I will be able to connect to a neo4j server. But it fails for both gradle and maven, and for different versions of spring data neo4j rest. And with a new-to-me exception of 401 Unauthorized when getting the pom:

* What went wrong:
  Could not resolve all dependencies for configuration ':compile'.
> Could not resolve org.neo4j:neo4j-rest-graphdb:1.9.
Required by:
  :recipeCrawlers:unspecified > org.springframework.data:spring-data-neo4j-rest:2.4.0.BUILD-SNAPSHOT
> Could not HEAD 'http://repo.spring.io/libs-snapshot/org/neo4j/neo4j-rest-graphdb/1.9/neo4j-rest-graphdb-1.9.pom'. Received status code 401 from server: Unauthorized

Anybody have an idea of what I'm am doing wrong

part of my build.gradle is:

buildscript {
repositories {
    maven { url 'http://m2.neo4j.org/content' }
    maven { url "http://repo.spring.io/libs-snapshot" }
    mavenLocal()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M5")
}
}

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

jar {
baseName = 'crawlers'
version =  '0.1.0'
} 

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

dependencies {
 compile("org.springframework.boot:spring-boot-starter:0.5.0.M5")
 compile("org.springframework.data:spring-data-mongodb:1.3.2.RELEASE")
 compile("com.google.guava:guava-collections:r03")
 compile("org.apache.commons:commons-lang3:3.0")
 compile 'org.springframework.data:spring-data-neo4j:2.4.0.BUILD-SNAPSHOT'
 compile 'org.springframework.data:spring-data-neo4j-rest:2.4.0.BUILD-SNAPSHOT'
 //    compile 'org.neo4j:neo4j-rest-graphdb:1.9'

 compile 'javax.validation:validation-api:1.1.0.Final'
 compile 'org.hibernate:hibernate-validator:5.0.1.Final'

 // compile 'org.neo4j:neo4j-cypher:'

 testCompile("junit:junit:4.11")
}

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

Using maven with the same dependencies, I get this error:

Could not resolve dependencies for project com.emaat-sample:jar:0.0.1-SNAPSHOT: Failed to   collect dependencies for [org.springframework.boot:spring-boot-starter:jar:0.5.0.M5 (compile), org.springframework.data:spring-data-neo4j:jar:2.4.0.BUILD-SNAPSHOT (compile), org.springframework.data:spring-data-neo4j-rest:jar:2.4.0.BUILD-SNAPSHOT (compile), junit:junit:jar:4.11 (test), org.mockito:mockito-core:jar:1.9.5 (test), org.hamcrest:hamcrest-library:jar:1.3 (test)]: Failed to read artifact descriptor for org.neo4j:neo4j-rest-graphdb:jar:1.9: Could not transfer artifact org.neo4j:neo4j-rest-graphdb:pom:1.9 from/to spring-snapshots (http://repo.spring.io/libs-snapshot): Not authorized, ReasonPhrase:Unauthorized. -> [Help 1]

My pom file: http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.emaat sample 0.0.1-SNAPSHOT sample

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>0.5.0.M5</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j</artifactId>
        <version>2.4.0.BUILD-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j-rest</artifactId>
        <version>2.4.0.BUILD-SNAPSHOT</version>
    </dependency>
</dependencies>

<!-- Package as an executable JAR -->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/libs-snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/libs-snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>
</project>
1
The spring-data-neo4j-rest dependency is here: repo.spring.io/libs-snapshot/org/springframework/data/… not sure why gradle wants to resolve org.neo4j:neo4j-rest-graphdb on the spring repo and not the m2.neo4j.org repoMichael Hunger
Hi Michael, thanks for taking the time to help. I have the same problem when using maven. I'm using spring boot to ease the setup, could this be a cause ? Will update the question with a maven pom file, and the exception that returns.stoffer
Please just try to add m2.neo4j.org as maven repo in the repository section.Michael Hunger
Removing the spring snapshot repository, and only using the 2.3.2.RELEASE versions of spring-data-neo4j and spring-data-neo4j-rest artifacts, and completly removing the dependencies for spring-boot makes the project compile. Now I just have some autowiring to setup up not having the spring-boot starterstoffer

1 Answers

3
votes

I had the same issue when trying to resolve the "org.restlet.jee:org.restlet.ext.servlet:2.1.1" dependency, as it was a transitive dependency for me. Turns out that "org.restlet.jee:org.restlet.ext.servlet:2.1.1" does not exist in Maven Central, so gradle is going to then try the Spring IO Repository. The Spring IO Repository is somewhat limited, and will throw a security exception for certain dependencies.

This seems to be the case for org.neo4j:neo4j-rest-graphdb:1.9 as well. A quick search shows that this is not present in Maven Central, so you'll have to add a new repository (I added mine before the Spring IO Repository). With adding the repository, I was able to keep using Spring Boot.

I did recreate your issue, and solved it by changing the repositories section to:

repositories {
    mavenCentral()
    maven { url "http://m2.neo4j.org/content/repositories/releases/" }
    maven { url "http://repo.spring.io/libs-snapshot" }
}