2012-06-16 42 views
0

當我做一個HTTP POST將在我的本地AppEngine上的研究與開發服務器DataNucleus將REST資源,服務器將引發此錯誤:錯誤使用DataNucleus將REST API

Caused by: java.lang.ClassNotFoundException: org.datanucleus.NucleusContext 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423) 
    at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356) 
    ... 37 more 

從它似乎什麼,使用Datnuclues REST API平臺不允許使用appengine嗎?

編輯: DataNucleus將在POM:

<dependency> 
    <groupId>com.google.appengine.orm</groupId> 
    <artifactId>datanucleus-appengine</artifactId> 
    <version>2.0.0</version> 
</dependency> 
<dependency> 
    <groupId>org.datanucleus</groupId> 
    <artifactId>datanucleus-core</artifactId> 
    <version>3.0.0-release</version> 
</dependency> 

<dependency> 
    <groupId>org.datanucleus</groupId> 
    <artifactId>datanucleus-api-jpa</artifactId> 
    <version>3.0.0-release</version> 
</dependency> 
<dependency> 
    <groupId>org.apache.geronimo.specs</groupId> 
    <artifactId>geronimo-jpa_2.0_spec</artifactId> 
    <version>1.0</version> 
</dependency> 

     <!-- Required by Datanucleus REST API --> 
     <dependency> 
      <groupId>org.datanucleus</groupId> 
      <artifactId>datanucleus-rest</artifactId> 
      <version>2.0.0-release</version> 
     </dependency> 
     <dependency> 
      <groupId>net.sf.flexjson</groupId> 
      <artifactId>flexjson</artifactId> 
      <version>2.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.datanucleus</groupId> 
      <artifactId>datanucleus-json</artifactId> 
      <version>2.0.0-release</version> 
     </dependency> 

下面是在WEB-INF/lib文件夾的DN相關的罐:

  • DataNucleus將靜止-2.0 .0-release.jar
  • datanucleus-json-2.0.0-release.jar
  • 個DataNucleus將核 - 3.0.0-release.jar
  • DataNucleus將-的AppEngine-2.0.0.jar
  • DataNucleus將-API的JP-A-3.0.0-release.jar

編輯:

通過使用v3.0 DN依賴項修復了最初的問題。

但是,現在當我嘗試從DN servlet的訪問REST資源,它拋出這個錯誤:

Error : An error occurred trying to instantiate an instance of the API adapter "org.datanucleus.api.jdo.JDOAdapter" (perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH?) : {1} 
org.datanucleus.exceptions.NucleusUserException: Error : An error occurred trying to instantiate an instance of the API adapter "org.datanucleus.api.jdo.JDOAdapter" (perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH?) : {1} 

回答

2

所以你使用DataNucleus將-API的休息(大概3.X)的一些版本,並且沒有必要的datanucleus-core(也是3.x)版本。這通常是什麼ClassNotFoundException意味着

+0

我添加到POM的依賴關係,現在我得到這個錯誤:java.lang.ClassNotFoundException:org.datanucleus.api.rest.RestServlet – xybrek

+0

我已經添加了POM和jar列表進入問題中,也許在運行時加載的罐子存在一些兼容性問題。 – xybrek

+0

爲什麼在使用datanucleus v3.0和其他jar時使用datanucleus-rest 2.0?最好只使用datanucleus-api-rest v3.0與datanucleus-core v3.0 – DataNucleus