简体   繁体   English

在Java应用程序中执行Neo4j的密码查询时的异常

[英]Exception in Executing Cypher Queries of Neo4j in Java Application

I am new to Neo4j Graph Database and I want to create CyperQueries from java Application . 我是Neo4j图形数据库的新手,我想从Java Application创建CyperQueries。 I am using the above neo4j manual 我正在使用上述neo4j手册

http://docs.neo4j.org/chunked/milestone/query-create.html

I am creating nodes from java APplication as follow 我正在从Java APplication创建节点,如下所示

public class CreateQuery
{
    public static final String DBPATH="D:/Neo4j/CQL";

    public static void main(String args[])
    {
        GraphDatabaseService path=new EmbeddedGraphDatabase(DBPATH);
        Transaction tx=path.beginTx();
        try
        {
        Map<String, Object> props  = new HashMap<String, Object>();
        props .put( "Firstnamename", "Sharon" );
        props .put( "lastname", "Eunis" );

        Map<String, Object> params = new HashMap<String, Object>();
        params.put( "props", props  );

        ExecutionEngine engine=new ExecutionEngine(path);
        ExecutionResult result=engine.execute( "create ({props})", params );
        System.out.println(result);
        tx.success();
        } 
        finally
        {
             tx.finish();
             path.shutdown();

        }
    }
}

I am getting the above error. 我收到上述错误。 I am not aware of this errors, please can any 1 help in solving as soon as posible . 我不知道此错误,请尽快解决任何1个问题。

Exception in thread "main" java.lang.NoClassDefFoundError: com/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap$Builder
    at org.neo4j.cypher.internal.LRUCache.<init>(LRUCache.scala:30)
    at org.neo4j.cypher.ExecutionEngine$$anon$1.<init>(ExecutionEngine.scala:84)
    at org.neo4j.cypher.ExecutionEngine.<init>(ExecutionEngine.scala:84)
    at com.neo4j.CreateQuery.main(CretaeQuery.java:33)
Caused by: java.lang.ClassNotFoundException: com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap$Builder
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 4 more

You may need to add the latest release of this library (ConcurrentLinkedHashMap for Java): 您可能需要添加该库的最新版本(ConcurrentLinkedHashMap for Java):

http://concurrentlinkedhashmap.googlecode.com/files/concurrentlinkedhashmap-lru-1.3.1.jar http://concurrentlinkedhashmap.googlecode.com/files/concurrentlinkedhashmap-lru-1.3.1.jar

The code you shared works fine. 您共享的代码工作正常。 I think the problem is with your import statements. 我认为问题在于您的导入语句。 They should be like this: 他们应该是这样的:

import java.util.HashMap;
import java.util.Map;
import org.neo4j.cypher.javacompat.ExecutionEngine;
import org.neo4j.cypher.javacompat.ExecutionResult;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.kernel.EmbeddedGraphDatabase;

It looks like a library error. 看起来像是库错误。 Perhaps you have imported the wrong version of something? 也许您输入了错误的版本?

Just in case, I should point out that you are meant to use the GDB factory for building an embedded instance: 为了以防万一,我应该指出,您打算使用GDB工厂来构建嵌入式实例:

graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);

Not sure that it will make any difference. 不确定是否会有所作为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM