ようへい

2012年12月5日水曜日

[GAE/J] slim3環境下でのエラー対処法覚え書き

先日GAE/Jのプロジェクトをslim3に移行したのですが、その際に躓いたエラーの対処法を書いておきます。

NoClassDefFoundError

エラー内容
Error for /hogehoge
java.lang.NoClassDefFoundError: Could not initialize class org.slim3.datastore.Datastore
 at org.slim3.datastore.DatastoreFilter.doFilter(DatastoreFilter.java:69)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:192)
 at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:157)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 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)
対処法
GAE/Jに必要なjarがwar/WEB-INF/libに存在しない場合に発生する。
eclipseで、プロジェクトのプロパティ»Google»AppエンジンでSDKを選びなおし、war/WEB-INF/libに必要なjarを取得する。

ExceptionInInitializerError

エラー内容
Error for /hogehoge
java.lang.ExceptionInInitializerError
 at org.slim3.datastore.DatastoreFilter.doFilter(DatastoreFilter.java:69)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:192)
 at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:157)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 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: org.slim3.util.WrapRuntimeException: An error occurred while creating a new instance of the class(org.slim3.datastore.DatastoreDelegate). Error message: com/google/appengine/api/datastore/DatastoreServiceConfig$Builder
 at org.slim3.util.ClassUtil.newInstance(ClassUtil.java:96)
 at org.slim3.datastore.Datastore.delegateClass(Datastore.java:82)
 at org.slim3.datastore.Datastore.initialize(Datastore.java:60)
 at org.slim3.datastore.Datastore.<clinit>(Datastore.java:52)
 ... 33 more
Caused by: java.lang.NoClassDefFoundError: com/google/appengine/api/datastore/DatastoreServiceConfig$Builder
 at org.slim3.datastore.AsyncDatastoreDelegate.setUp(AsyncDatastoreDelegate.java:119)
 at org.slim3.datastore.AsyncDatastoreDelegate.<init>(AsyncDatastoreDelegate.java:93)
 at org.slim3.datastore.DatastoreDelegate.<init>(DatastoreDelegate.java:63)
 at org.slim3.datastore.DatastoreDelegate.<init>(DatastoreDelegate.java:53)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
 at java.lang.Class.newInstance0(Class.java:372)
 at java.lang.Class.newInstance(Class.java:325)
 at org.slim3.util.ClassUtil.newInstance(ClassUtil.java:94)
 ... 36 more
Caused by: java.lang.ClassNotFoundException: com.google.appengine.api.datastore.DatastoreServiceConfig$Builder
 at com.google.appengine.runtime.Request.process-6576c13a5e193afa(Request.java)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
 at org.slim3.datastore.AsyncDatastoreDelegate.setUp(AsyncDatastoreDelegate.java:119)
 at org.slim3.datastore.AsyncDatastoreDelegate.<init>(AsyncDatastoreDelegate.java:93)
 at org.slim3.datastore.DatastoreDelegate.<init>(DatastoreDelegate.java:63)
 at org.slim3.datastore.DatastoreDelegate.<init>(DatastoreDelegate.java:53)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
 at java.lang.Class.newInstance0(Class.java:372)
 at java.lang.Class.newInstance(Class.java:325)
 at org.slim3.util.ClassUtil.newInstance(ClassUtil.java:94)
 at org.slim3.datastore.Datastore.delegateClass(Datastore.java:82)
 at org.slim3.datastore.Datastore.initialize(Datastore.java:60)
 at org.slim3.datastore.Datastore.<clinit>(Datastore.java:52)
 at org.slim3.datastore.DatastoreFilter.doFilter(DatastoreFilter.java:69)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:192)
 at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:157)
 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$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
対処法
src/META-INF/jdoconfig.xmlが無ければ作る。
repackaged-appengine-jakarta-standard-1.1.2.jar をwar/WEB-INF/libにコピーし、ビルドパスに通す。
jdoconfig.xmlは以下を参考に。
JDO を利用したデータストアの使用 - Google App Engine — Google Developers
https://developers.google.com/appengine/docs/java/gettingstarted/usingdatastore?hl=ja
関連記事

0 件のコメント:

コメントを投稿