gpt4 book ai didi

java - 使用 Datanucleus Rest API 时出现错误

转载 作者:行者123 更新时间:2023-12-02 07:44:45 25 4
gpt4 key购买 nike

当我对本地 Appengine 开发服务器中的 Datanucleus Rest 资源执行 Http POST 时,服务器会抛出此错误:

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

从表面上看,平台不允许在 appengine 上使用 Datnuclues Rest API?

编辑: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 相关的 jar:

  • datanucleus-rest-2.0.0-release.jar
  • datanucleus-json-2.0.0-release.jar
  • datanucleus-core-3.0.0-release.jar
  • datanucleus-appengine-2.0.0.jar
  • datanucleus-api-jpa-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}

最佳答案

因此,您使用某些版本的 datanucleus-api-rest(大概是 3.x),并且没有必要版本的 datanucleus-core(也是 3.x)。这通常就是 ClassNotFoundException 的含义

关于java - 使用 Datanucleus Rest API 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11066312/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com