2017-09-17 4 views
1

Eclipse에서 maven 종속성을 사용하고 볼트 프로토콜을 사용하여 neo4j 및 java에 연결하려고합니다. MacOS에서 응용 프로그램을 실행 중입니다. Eclipse 3 및 Java 버전 8과 jre 1.8을 사용하고 있습니다. 이것은 내 pom.xml 파일입니다 **Eclipse에서 bolt 프로토콜을 사용하여 작동하도록 java 및 neo4j를 실행하는 방법

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

**

이, 나는이 모든 오류를 얻고 응용 프로그램을 실행 한 후 된 .java 파일

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(); 
     } 
    } 

에서 호출하는 방법입니다

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 

내 모든 오류를 파악하는 데 도움이됩니다.

다른 프로세스가 잠금되어

답변

1

,

프로세스를 죽이는 당신이 해결되지 않은 경우

ps aux | grep java 

ps aux | grep neo4j 

또는

이 예외의 설명

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) 

를 읽어보십시오 죽일 필요하다 디렉토리에 쓰기 권한을 추가하려면

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

나는 여전히 같은 오류가 발생했습니다. –

+0

@AruW 내 대답 – IddoE

+0

에서 명령을 디렉토리에 쓰기 권한을 추가하려고뿐만 아니라 https://support.apple.com/kb/PH18894?locale=ko_US뿐만 아니라이 페이지에서 지침을 따라했습니다. 아직도 내 문제를 해결에서 행운을 –