2017-09-17 1 views
1

J'utilise les dépendances maven dans Eclipse et essaye de connecter neo4j et java en utilisant le protocole bolt. Je cours l'application dans MacOS. J'utilise Eclipse 3 et Java version 8 et jre 1.8. Ceci est mon pom.xml **Comment utiliser java et neo4j pour travailler en utilisant le protocole bolt en eclipse?

<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>org.neo4j</groupId> 
    <artifactId>neo4j</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 
    <name>neo4j</name> 
    <url>http://maven.apache.org</url> 
    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
    <dependencies> 
    <dependency> 
     <groupId>org.neo4j.driver</groupId> 
     <artifactId>neo4j-java-driver</artifactId> 
     <version>1.2.1</version> 
    </dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.neo4j</groupId> 
     <artifactId>neo4j</artifactId> 
     <version>3.1.4</version> 
     <scope>provided</scope> 
    </dependency> 
    </dependencies> 
</project> 

**

Cette méthode est appelée dans .java fichier

void createDatabase() 
    { 
     GraphDatabaseService dfs = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath); 
     System.out.println("Database created!!"); 
     Config noSSL = Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig(); 

     try(Driver dri = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("neo4j", "hello"), noSSL)) 
     { 
      System.out.println("Database connected"); 

      Session session = dri.session(); 
      session.run("CREATE(a:Persona{name:{name}, title:{title}})", parameters("name","Aruna","title","Bhakt")); 
      System.out.println("\n\t1.CREATED"); 

      StatementResult result =session.run("MATCH(a:Persona) WHERE a.name = {name}" + 
                "RETURN a.name AS name, a.title AS title", 
                parameters("name","Aruna")); 
      System.out.println("\n\t2.Match"); 

      while(result.hasNext()) 
      { 
       Record record = result.next(); 
       System.out.println(record.get("title").asString() + " " + record.get("name").asString()); 

      } 
      System.out.println("\n\t3.Found Record"); 

      session.close(); 
      dri.close(); 
     } 
    } 

Après l'exécution de l'application, je reçois toutes ces erreurs

Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory, /Users/arundhatiwahane/Documents/Neo4j/default.graphdb 
    at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:199) 
    at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:130) 
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:101) 
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.lambda$createDatabaseCreator$0(GraphDatabaseFactory.java:89) 
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$$Lambda$1/1130478920.newDatabase(Unknown Source) 
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:183) 
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:66) 
    at com.sampledb.createDatabase(sampledb.java:41) 
    at com.sampledb.main(sampledb.java:34) 
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component '[email protected]' was successfully initialized, but failed to start. Please see attached cause exception. 
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:443) 
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107) 
    at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:195) 
    ... 8 more 
Caused by: org.neo4j.kernel.StoreLockException: Store and its lock file has been locked by another process: /Users/arundhatiwahane/Documents/Neo4j/default.graphdb/store_lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access) 
    at org.neo4j.kernel.internal.StoreLocker.storeLockException(StoreLocker.java:94) 
    at org.neo4j.kernel.internal.StoreLocker.checkLock(StoreLocker.java:80) 
    at org.neo4j.kernel.internal.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:40) 
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:433) 
    ... 10 more 

Aidez-moi à comprendre toutes mes erreurs.

Répondre

1

Un autre processus de verrouillage, tuez-le

essayer

ps aux | grep neo4j 

ou

ps aux | grep java 

lire la description

Caused by: org.neo4j.kernel.StoreLockException: Store and its lock file has been locked by another process: /Users/arundhatiwahane/Documents/Neo4j/default.graphdb/store_lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access) 

votre exception si tuant le processus n'a pas vous résoudre avoir besoin pour ajouter l'autorisation d'écriture au répertoire

chmod -R 777 /Users/arundhatiwahane/Documents/Neo4j/ 
+0

Je l'ai fait, toujours la même erreur. –

+0

@AruW essayez d'ajouter l'autorisation d'écriture dans le répertoire, commande dans ma réponse – IddoE

+0

Essayé le même et également suivi les instructions de cette page ainsi https://support.apple.com/kb/PH18894?locale=en_US. Toujours pas de chance de résoudre mon problème –