2012-07-20 61 views
2

我有一个新建立的neo4j-rest-graphdb-1.8-SNAPSHOT.jar。但是,我出了问题。Neo4j爪哇休息绑定:NoClassDefFoundError

我有基本的/默认安装的Neo4j的运行,使用有效的图形存储配置:

Neo4j的版本

图形数据库内核1.8.M05

OS

Ubuntu 12.04 LTS

Java版本

“1.6.0_24” OpenJDK的运行时环境(1.11.1 IcedTea6)(6b24-1.11.1-4ubuntu3) OpenJDK的64位服务器VM(构建20.0-B12,混合模式)

的卷曲请求提出一切工作的很好:

$ curl http://localhost:7474/db/data/ -i 
HTTP/1.1 200 OK 
Content-Length: 809 
Content-Encoding: UTF-8 
Content-Type: application/json 
Access-Control-Allow-Origin: * 
Server: Jetty(6.1.25) 

{ 
    "extensions" : { 
    "CypherPlugin" : { 
     "execute_query" :  "http://localhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query" 
    }, 
    "GremlinPlugin" : { 
     "execute_script" :  "http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute_script" 
    } 
    }, 
    "node" : "http://localhost:7474/db/data/node", 
    "reference_node" : "http://localhost:7474/db/data/node/0", 
    "node_index" : "http://localhost:7474/db/data/index/node", 
    "relationship_index" : "http://localhost:7474/db/data/index/relationship", 
    "extensions_info" : "http://localhost:7474/db/data/ext", 
    "relationship_types" : "http://localhost:7474/db/data/relationship/types", 
    "batch" : "http://localhost:7474/db/data/batch", 
    "cypher" : "http://localhost:7474/db/data/cypher", 
    "neo4j_version" : "1.8.M05-1-ge9cdca9" 

但是,尝试下面一行:

GraphDatabaseService graph = new RestGraphDatabase(“http:// localhost:7474/db/data /”);

......产生一个例外:

Exception in thread "main" java.lang.NoClassDefFoundError:  javax/ws/rs/core/Response$StatusType 
    at org.neo4j.rest.graphdb.RestAPIFacade.<init>(RestAPIFacade.java:265) 
    at org.neo4j.rest.graphdb.RestGraphDatabase.<init>(RestGraphDatabase.java:44) 
    at com.tester.api.Neo4j.importer(Neo4j.java:185) 
    at com.tester.api.Neo4j.main(Neo4j.java:97) 
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.core.Response$StatusType 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
... 4 more 

回答

2

好拉下它的DEPS,我认为它最后全部胶凝我:

从顶部:

  1. 从Maven 2升级到Maven 3
  2. 删除了〜/ .m2/repository以删除之前下载的任何依赖项
  3. 然后,在java-rest-binding git仓库中,我运行mvn dependency:copy-dependencies以获取所有依赖项的副本,然后将它们(目标/依赖项文件夹的内容)添加到我的构建路径中(感谢Peter)
  4. 在Eclipse中这个从源文件(复制/ main/java/org/neo4j到我的项目的'org'文件夹)的其余包给了我一个缺少'批量请求'类型包neo4j
  5. 所以,然后我运行mvn package另一个新鲜/克隆/检出的java-rest-binding git回购并复制结果。罐子(neo4j-rest-graphdb-1.8-SNAPSHOT.jar)到我的项目的lib(连同所有的依赖

我已经做了一些初步的测试,这似乎是现在的工作!

如果上述步骤显示了我使用Maven天真,你知道简明指南避免今后此类问题的,请与大家共享!

谢谢!

+0

从Neo4j Group(来自Peter)引用:这很有用,但你很幸运。将所有jar打包成一个jar文件可能会覆盖不同内容下不同内容下存在的文件,如java服务加载器文件。您没有这些,但请注意是否包含e。 G。注册更多缓存类型的内核和企业罐。 – Rob 2012-07-26 15:14:20

2

这看起来像一个丢失的依赖。您是否确定通过maven包含所有依赖关系,如https://github.com/neo4j/java-rest-binding/blob/master/pom.xml中所述?你可以从源代码编译该项目,并通过做

mvn dependency:copy-dependencies 

/彼得

+0

感谢Peter,我试过了,但它没有工作(同样的错误)。它的构建,然后我将jar文件复制到我的项目的lib文件夹。构建路径中的其他jar包括:geronimo-jta_1.1_spec-1.1.1.jar,json-simple-1.1.1.jar,lucene-core-3.5.0.jar,mysql-connector-java-5.0.8- bin.jar,neo4j-cypher-1.8.M05.jar,neo4j-graph-algo-1.8.M05.jar,neo4j-graph-matching-1.8.M05.jar,neo4j-jmx-1.8.M05.jar,neo4j- kernel-1.8.M05.jar,neo4j-lucene-index-1.8.M05.jar,neo4j-shell-1.8.M05.jar,neo4j-udc-1.8.M05.jar,org.apache.servicemix.bundles.jline- 0.9.94_1.jar,scala-library-2.9.1-1.jar,server-api-1.8.M05.jar – Rob 2012-07-23 16:18:38

1

我有同样的问题,发现我没有球衣。我试着去所有的依赖关系,但没”不要拿这个罐子,所以解决方案可以..只是下来加载运动衫捆绑1.13-b01.jar。

P.S. :这可能不是解决问题的最好方法,因为可能存在很多依赖关系,但在这种特殊情况下,它只是缺少运动衫,所以它可以这样工作:-)