2

我使用 Google 应用引擎 -GAE 创建了一个示例 GWT 应用程序,我创建了一个实体并将其保存在服务层上,工作正常,数据存储。

所以我开始在我的服务层上添加小部件和更多类,当我尝试创建 EntityManager 时,我得到:

org.datanucleus.exceptions.ClassNotResolvedException对于非实体类,例如小部件,我不知道为什么 Datanucleus 试图增强没有 @Entity 注释的类。

我在 ORM 下配置了 Google Plugin Eclipse 以仅增强 dto 包中的 bean 并删除 /src 条目。

它永远不会起作用,我只需要能够告诉 DN 不要只增强它看到其 CLASSPATH 的每个类。

任何帮助将不胜感激。

我正在使用 GAE 1.7.5 版和 GWT 2.5 和 GXT 2.5.5。

例外:

Initializing App Engine server
Mar 8, 2013 5:07:51 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory 'C:\dev\projects\org\me\workspace\lottoshop\war' is not an EAR directory. File C:\dev\projects\org\me\workspace\lottoshop\war\appengine-application.xmlappengine-application.xml not detected.
Mar 8, 2013 5:07:51 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory 'C:\dev\projects\org\me\workspace\lottoshop\war' is not an EAR directory. File C:\dev\projects\org\me\workspace\lottoshop\war\appengine-application.xmlappengine-application.xml not detected.
Mar 8, 2013 5:07:51 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory 'C:\dev\projects\org\me\workspace\lottoshop\war' is not an EAR directory. File C:\dev\projects\org\me\workspace\lottoshop\war\appengine-application.xmlappengine-application.xml not detected.
Mar 8, 2013 5:07:51 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory 'C:\dev\projects\org\me\workspace\lottoshop\war' is not an EAR directory. File C:\dev\projects\org\me\workspace\lottoshop\war\appengine-application.xmlappengine-application.xml not detected.
Mar 8, 2013 5:07:51 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\dev\projects\org\me\workspace\lottoshop\war\WEB-INF/appengine-web.xml
Mar 8, 2013 5:07:51 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed C:\dev\projects\org\me\workspace\lottoshop\war\WEB-INF/web.xml
Mar 8, 2013 5:07:51 PM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
INFO: Overwriting system property key 'java.util.logging.config.file', value 'C:\dev\tools\gae\appengine-java-sdk-1.7.5\appengine-java-sdk-1.7.5\config\sdk\logging.properties' with value 'WEB-INF/logging.properties' from 'C:\dev\projects\org\me\workspace\lottoshop\war\WEB-INF\appengine-web.xml'
Mar 8, 2013 5:07:51 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
Mar 8, 2013 5:07:55 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
Mar 8, 2013 5:07:57 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Started SelectChannelConnector@0.0.0.0:8888
Mar 8, 2013 5:07:57 PM com.google.appengine.tools.development.AbstractServer startup
INFO: Server default is running at http://localhost:8888/
Mar 8, 2013 5:07:57 PM com.google.appengine.tools.development.AbstractServer startup
INFO: The admin console is running at http://localhost:8888/_ah/admin
Mar 8, 2013 5:07:57 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: Dev App Server is now running
mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.22 (khtml, like gecko) chrome/25.0.1364.152 safari/537.22
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.shared.SearchResponse was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.shared.FieldVerifier was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.LottoType was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class com.extjs.gxt.samples.resources.client.TestData was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.server.LottoShopDAOServiceImpl was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.resources.Resources was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.LottoShopServiceAsync was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class com.extjs.gxt.samples.resources.client.model.Customer was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.shared.SearchRequest was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.GameTypes was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class com.extjs.gxt.samples.resources.client.icons.ExampleIcons was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.server.LottoShopServiceImpl was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.LottoShopDAOServiceAsync was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.Lottoshop was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.AppEvents was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.server.EMF was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.LottoShopService was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.shared.Constants was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.shared.MultiplePlayersFoundException was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class com.extjs.gxt.samples.resources.client.images.ExampleImages was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.LottoShopDAOService was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.resources.TestData was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class com.extjs.gxt.samples.resources.client.Resources was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM org.datanucleus.metadata.MetaDataManager loadPersistenceUnit
WARNING: Class co.za.fwc.webapp.lottery.client.icons.ExampleIcons was specified in persistence-unit transactions-optional but not annotated, so ignoring
Mar 8, 2013 5:15:57 PM com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract co.za.fwc.webapp.lottery.shared.dto.Player co.za.fwc.webapp.lottery.client.LottoShopDAOService.find(java.lang.String) throws co.za.fwc.webapp.lottery.shared.MultiplePlayersFoundException' threw an unexpected exception: java.lang.ExceptionInInitializerError
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:61)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:409)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
    at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
    at co.za.fwc.webapp.lottery.server.LottoShopDAOServiceImpl.find(LottoShopDAOServiceImpl.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
    ... 38 more
Caused by: javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "transactions-optional" after trying the following discovered implementations: org.datanucleus.api.jpa.PersistenceProviderImpl from provider: org.datanucleus.api.jpa.PersistenceProviderImpl
    at javax.persistence.Persistence.createPersistenceException(Persistence.java:242)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:184)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:70)
    at co.za.fwc.webapp.lottery.server.EMF.<clinit>(EMF.java:7)
    ... 49 more
Caused by: org.datanucleus.exceptions.NucleusUserException: Errors were encountered when loading the MetaData for the persistence-unit "transactions-optional". See the nested exceptions for details
    at org.datanucleus.metadata.MetaDataManager.loadPersistenceUnit(MetaDataManager.java:979)
    at org.datanucleus.api.jpa.JPAEntityManagerFactory.initialiseNucleusContext(JPAEntityManagerFactory.java:754)
    at org.datanucleus.api.jpa.JPAEntityManagerFactory.initialise(JPAEntityManagerFactory.java:417)
    at org.datanucleus.api.jpa.JPAEntityManagerFactory.<init>(JPAEntityManagerFactory.java:380)
    at org.datanucleus.api.jpa.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:91)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:150)
    ... 51 more
Caused by: org.datanucleus.exceptions.ClassNotResolvedException: Class "com.extjs.gxt.samples.resources.client.model.MailItem" was not found in the CLASSPATH. Please check your specification and your CLASSPATH.
    at org.datanucleus.JDOClassLoaderResolver.classForName(JDOClassLoaderResolver.java:245)
    at org.datanucleus.JDOClassLoaderResolver.classForName(JDOClassLoaderResolver.java:410)
    at org.datanucleus.metadata.MetaDataManager.loadPersistenceUnit(MetaDataManager.java:954)
    ... 56 more

com.google.gwt.user.client.rpc.StatusCodeException: 500 The call failed on the server; see server log for details
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
    at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Thread.java:662)
4

1 回答 1

5

我遇到了类似的问题,我正在使用 GAE-1.7.7、GWT-2.5.1 和 Hibernate Validator。一旦我打开验证,客户端验证运行良好,但服务器端持久性搞砸了,显示类似的 ClassNotResolvedException 异常

在构建 EntityManager 时,在扫描类时出现了一些问题。解决方案是禁用实体的自动扫描,并在构建 PersistenceUnit 时明确告知要加载哪些类

<provider>请修改您的 persistence.xml 并在标签下方添加以下行

<persistence-unit name="transactions-optional">
    <provider>org.datanucleus.jpa.PersistenceProviderImpl</provider>
    <class>your.package.Entity1</class>
    <class>your.package.Entity2</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>

这应该有效。

于 2013-04-15T20:37:41.833 回答