2012-12-28 46 views
4

雖然我試圖在AppEngine中使用低級DataStore API,但我得到一個有趣的ClassNotFoundException。這種異常發生在雲服務器上,而不是在本地實例中。本地我使用appengine-java-sdk-1.7.4AppEngine ClassNotFoundException:com.google.appengine.api.datastore.DatastoreServiceFactory

java.lang.NoClassDefFoundError: com/google/appengine/api/datastore/DatastoreServiceFactory 
    at org.himadri.scradiolisteners.server.FetchingServlet.writeDataLowLevel(FetchingServlet.java:47) 
    at org.himadri.scradiolisteners.server.FetchingServlet.doGet(FetchingServlet.java:39) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 
    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.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:102) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35) 
    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 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.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:266) 
    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.headerComplete(HttpConnection.java:923) 
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76) 
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) 
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146) 
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:447) 
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454) 
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461) 
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:703) 
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:338) 
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:330) 
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458) 
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251) 
    at java.lang.Thread.run(Thread.java:679) 
Caused by: java.lang.ClassNotFoundException: com.google.appengine.api.datastore.DatastoreServiceFactory 
    at com.google.appengine.runtime.Request.process-e485d13152ebc944(Request.java) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266) 
    at org.himadri.scradiolisteners.server.FetchingServlet.writeDataLowLevel(FetchingServlet.java:47) 
    at org.himadri.scradiolisteners.server.FetchingServlet.doGet(FetchingServlet.java:39) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 
    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 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 
    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 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.headerComplete(HttpConnection.java:923) 
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) 
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454) 
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461) 
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:703) 
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:338) 
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:330) 
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458) 
    ... 1 more 
+0

錯誤本身已經存在。它也可以幫助您發佈產生此錯誤的代碼 – KyelJmD

回答

4

聽起來像是我的兩件事之一。

1:您正嘗試在單元測試中運行GAE代碼,在這種情況下,您需要使用this page中指定的代碼。

2:您沒有將所有必需的jar添加到類路徑中。

2

問題是我並沒有包括在上傳的內容appengine-api-1.0-sdk.jar

<dependency> 
    <groupId>com.google.appengine</groupId> 
    <artifactId>appengine-api-1.0-sdk</artifactId> 
    <version>1.7.4</version> 
    <scope>provided</scope> 
</dependency> 

通過刪除範圍:提供行中,問題已經解決。我只是不認爲這個API在雲服務器上不可用。

+0

在您上傳到GAE的任何應用程序中,您需要提供第三方依賴項。我很高興你能解決這個問題。感謝,ecbrodie – ecbrodie

+0

。有趣的是,這個appengine-api不是第三方庫,但是container-services自己:-) – kavai77