首先,这是我第一次来这里,我来自巴西,我也想提前感谢所有能帮助我的人。此外,这是我第一次使用GAE,我非常喜欢这项服务。我已经和GAE合作了一段时间,我使用GAE非常成功。
我正在尝试在GAE中执行持久性,我有错误:
javax.jdo.JDOFatalUserException:Class org.datanucleus.api.jdo 找不到.JDOPersistenceManagerFactory。
我的追踪者:
[INFO] set 07, 2014 12:03:28 PM com.google.api.server.spi.SystemServiceServlet i
nit
[INFO] INFORMAÇÕES: SPI restricted: true
[INFO] set 07, 2014 12:03:34 PM com.google.api.server.spi.SystemService invokeSe
rviceMethod
[INFO] INFORMAÇÕES: cause={0}
[INFO] java.lang.ExceptionInInitializerError
[INFO] at com.ufscar.Greetings.listGreeting(Greetings.java:47)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:483)
[INFO] at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemSer
vice.java:359)
[INFO] at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceS
ervlet.java:160)
[INFO] at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceSe
rvlet.java:118)
[INFO] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[INFO] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[INFO] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511
)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1166)
[INFO] at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocke
tFilter.java:74)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.tools.development.ResponseRewriterFilter.doFilte
r(ResponseRewriterFilter.java:127)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.tools.development.HeaderVerificationFilter.doFil
ter(HeaderVerificationFilter.java:34)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(Serve
BlobFilter.java:63)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter
(TransactionCleanupFilter.java:43)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.tools.development.StaticFileFilter.doFilter(Stat
icFileFilter.java:125)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.tools.development.DevAppServerModulesFilter.doDi
rectRequest(DevAppServerModulesFilter.java:366)
[INFO] at com.google.appengine.tools.development.DevAppServerModulesFilter.doDi
rectModuleRequest(DevAppServerModulesFilter.java:349)
[INFO] at com.google.appengine.tools.development.DevAppServerModulesFilter.doFi
lter(DevAppServerModulesFilter.java:116)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
88)
[INFO] at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav
a:216)
[INFO] at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1
82)
[INFO] at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
65)
[INFO] at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
[INFO] at com.google.appengine.tools.development.DevAppEngineWebAppContext.hand
le(DevAppEngineWebAppContext.java:98)
[INFO] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
52)
[INFO] at com.google.appengine.tools.development.JettyContainerService$ApiProxy
Handler.handle(JettyContainerService.java:491)
[INFO] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
52)
[INFO] at org.mortbay.jetty.Server.handle(Server.java:326)
[INFO] at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54
2)
[INFO] at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnectio
n.java:938)
[INFO] at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
[INFO] at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
[INFO] at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
[INFO] at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
va:409)
[INFO] at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j
ava:582)
[INFO] Caused by: javax.jdo.JDOFatalUserException: Class org.datanucleus.api.jdo
.JDOPersistenceManagerFactory was not found.
[INFO] NestedThrowables:
[INFO] java.lang.ClassNotFoundException: org.datanucleus.api.jdo.JDOPersistenceM
anagerFactory
[INFO] at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementatio
n(JDOHelper.java:1175)
[INFO] at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:808)
[INFO] at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1093)
[INFO] at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:919)
[INFO] at com.ufscar.PMF.<clinit>(PMF.java:8)
[INFO] ... 45 more
[INFO] Caused by: java.lang.ClassNotFoundException: org.datanucleus.api.jdo.JDOP
ersistenceManagerFactory
[INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
[INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
[INFO] at java.security.AccessController.doPrivileged(Native Method)
[INFO] at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
[INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[INFO] at com.google.appengine.tools.development.IsolatedAppClassLoader.loadCla
ss(IsolatedAppClassLoader.java:216)
[INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[INFO] at java.lang.Class.forName0(Native Method)
[INFO] at java.lang.Class.forName(Class.java:340)
[INFO] at javax.jdo.JDOHelper$18.run(JDOHelper.java:2018)
[INFO] at javax.jdo.JDOHelper$18.run(JDOHelper.java:2016)
[INFO] at java.security.AccessController.doPrivileged(Native Method)
[INFO] at javax.jdo.JDOHelper.forName(JDOHelper.java:2015)
[INFO] at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementatio
n(JDOHelper.java:1162)
[INFO] ... 49 more
[INFO]
[INFO] set 07, 2014 12:03:34 PM com.google.api.server.spi.SystemService invokeSe
rviceMethod
[INFO] GRAVE: null
[INFO] java.lang.ExceptionInInitializerError
[INFO] at com.ufscar.Greetings.listGreeting(Greetings.java:47)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:483)
[INFO] at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemSer
vice.java:359)
[INFO] at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceS
ervlet.java:160)
[INFO] at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceSe
rvlet.java:118)
[INFO] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[INFO] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[INFO] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511
)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1166)
[INFO] at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocke
tFilter.java:74)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.tools.development.ResponseRewriterFilter.doFilte
r(ResponseRewriterFilter.java:127)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.tools.development.HeaderVerificationFilter.doFil
ter(HeaderVerificationFilter.java:34)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(Serve
BlobFilter.java:63)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter
(TransactionCleanupFilter.java:43)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.tools.development.StaticFileFilter.doFilter(Stat
icFileFilter.java:125)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at com.google.appengine.tools.development.DevAppServerModulesFilter.doDi
rectRequest(DevAppServerModulesFilter.java:366)
[INFO] at com.google.appengine.tools.development.DevAppServerModulesFilter.doDi
rectModuleRequest(DevAppServerModulesFilter.java:349)
[INFO] at com.google.appengine.tools.development.DevAppServerModulesFilter.doFi
lter(DevAppServerModulesFilter.java:116)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet
Handler.java:1157)
[INFO] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
88)
[INFO] at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav
a:216)
[INFO] at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1
82)
[INFO] at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
65)
[INFO] at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
[INFO] at com.google.appengine.tools.development.DevAppEngineWebAppContext.hand
le(DevAppEngineWebAppContext.java:98)
[INFO] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
52)
[INFO] at com.google.appengine.tools.development.JettyContainerService$ApiProxy
Handler.handle(JettyContainerService.java:491)
[INFO] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
52)
[INFO] at org.mortbay.jetty.Server.handle(Server.java:326)
[INFO] at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54
2)
[INFO] at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnectio
n.java:938)
[INFO] at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
[INFO] at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
[INFO] at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
[INFO] at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
va:409)
[INFO] at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j
ava:582)
[INFO] Caused by: javax.jdo.JDOFatalUserException: Class org.datanucleus.api.jdo
.JDOPersistenceManagerFactory was not found.
[INFO] NestedThrowables:
[INFO] java.lang.ClassNotFoundException: org.datanucleus.api.jdo.JDOPersistenceM
anagerFactory
[INFO] at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementatio
n(JDOHelper.java:1175)
[INFO] at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:808)
[INFO] at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1093)
[INFO] at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:919)
[INFO] at com.ufscar.PMF.<clinit>(PMF.java:8)
[INFO] ... 45 more
[INFO] Caused by: java.lang.ClassNotFoundException: org.datanucleus.api.jdo.JDOP
ersistenceManagerFactory
[INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
[INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
[INFO] at java.security.AccessController.doPrivileged(Native Method)
[INFO] at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
[INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[INFO] at com.google.appengine.tools.development.IsolatedAppClassLoader.loadCla
ss(IsolatedAppClassLoader.java:216)
[INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[INFO] at java.lang.Class.forName0(Native Method)
[INFO] at java.lang.Class.forName(Class.java:340)
[INFO] at javax.jdo.JDOHelper$18.run(JDOHelper.java:2018)
[INFO] at javax.jdo.JDOHelper$18.run(JDOHelper.java:2016)
[INFO] at java.security.AccessController.doPrivileged(Native Method)
[INFO] at javax.jdo.JDOHelper.forName(JDOHelper.java:2015)
[INFO] at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementatio
n(JDOHelper.java:1162)
[INFO] ... 49 more
[INFO]
我插入的地方:
MyBean p = new MyBean(la,lo);
PersistenceManager pm = PMF.get().getPersistenceManager();
try{
pm.makePersistent(p);
} finally {
pm.close();
}
我正在使用Maven,他在META-INF中附带了一个文件persistence.xml,但我创建了一个jdoconfig:
<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
<persistence-manager-factory name="transactions-optional">
<property name="javax.jdo.PersistenceManagerFactoryClass"
value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
<property name="javax.jdo.option.ConnectionURL" value="appengine"/>
<property name="javax.jdo.option.NontransactionalRead" value="true"/>
<property name="javax.jdo.option.NontransactionalWrite" value="true"/>
<property name="javax.jdo.option.RetainValues" value="true"/>
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
</persistence-manager-factory>
</jdoconfig>
的pom.xml:
http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT;
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.ufscar</groupId>
<artifactId>tcc</artifactId>
<properties>
<appengine.app.version>1</appengine.app.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<prerequisites>
<maven>3.1.0</maven>
</prerequisites>
<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.10</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-endpoints</artifactId>
<version>1.9.10</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0.1</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>1.9.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>1.9.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application-->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.1</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>
<!-- the list has a default value of ** -->
<includes>
<include>WEB-INF/*.discovery</include>
<include>WEB-INF/*.api</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.10</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<!-- Comment in the below snippet to bind to all IPs instead of just localhost -->
<!-- address>0.0.0.0</address>
<port>8080</port -->
<!-- Comment in the below snippet to enable local debugging with a remove debugger
like those included with Eclipse or IntelliJ -->
<!-- jvmFlags>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
</jvmFlags -->
</configuration>
<executions>
<execution>
<goals>
<goal>endpoints_get_discovery_doc</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<versionRange>2.1.1</versionRange>
<goals>
<goal>exploded</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<versionRange>1.1.4</versionRange>
<goals>
<goal>enhance</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</build>
有人?
答案 0 :(得分:1)
如果您持续使用JDO with GAE/Datastore,则需要
org.datanucleus : datanucleus-core, datanucleus-api-jdo v3.1.x
com.google.appengine.orm : datanucleus-appengine v2.1.x
在增强时添加到datanucleus-enhancer v3.1.x(除非通过maven插件完成)
答案 1 :(得分:1)
我在Eclipse中通过输入项目属性 - Google - App Engine并将Datanucleus JDO / JPA版本从未指定的版本切换为2来克服了这个错误。 (如果重要的话,我的跟踪转储顶部的错误是java.lang.ExceptionInInitializerError。)
答案 2 :(得分:0)
很抱歉,如果这有点晚了,但我一直在使用GAE进行一些项目并且每次都遇到此错误,因为文档中很容易遗漏这些错误。
在应用程序war/WEB-INF/classes/META-INF/
目录中,创建一个名为jdoconfig.xml
的文件,其中包含以下内容;
<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
<persistence-manager-factory name="transactions-optional">
<property name="javax.jdo.PersistenceManagerFactoryClass"
value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
<property name="javax.jdo.option.ConnectionURL" value="appengine"/>
<property name="javax.jdo.option.NontransactionalRead" value="true"/>
<property name="javax.jdo.option.NontransactionalWrite" value="true"/>
<property name="javax.jdo.option.RetainValues" value="true"/>
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
<property name="datanucleus.appengine.singletonPMFForName" value="true"/>
</persistence-manager-factory>
`
这指定JDOPersistenceManagerFactory实例,其名称为&#34; transactions-optional&#34;