将 Objectify 与 GAE 一起使用时 ObjectifyService 的 NoClassDefFoundError
NoClassDefFoundError for ObjectifyService when using Objectify with GAE
我已将 objectify-5.1.5-sources.jar 添加到我的 WEB-INF\lib
下的 GAE 项目中,并将 web.xml
文件修改为
...
<!-- objectify filter -->
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
...
但是当我部署到 app-engine 时出现以下错误
Uncaught exception from servlet
javax.servlet.UnavailableException: com.googlecode.objectify.ObjectifyFilter
at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:79)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:81)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:199)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:174)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:134)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:527)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:745)
我的 GAE 是 1.9.18
更新:将 jar 更改为 objectify-5.1.5.jar
后出现更多错误跟踪
Uncaught exception from servlet
java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.objectify.ObjectifyService
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:47)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
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.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
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:254)
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:527)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:745)
不要将随机 jar 文件添加到您的项目中。你会让你的问题变得更糟。源 jar 不属于类路径。
您是否完全按照设置说明进行操作?
https://code.google.com/p/objectify-appengine/wiki/Setup
请注意,您还需要 Guava jar。尽管 Maven 很糟糕,但它比手动管理依赖关系要好得多。
如https://code.google.com/p/objectify-appengine/wiki/Setup所述,
我添加了
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我的 web.xml
用于 objectify v5.1.9 并使用
将我的部署到虚拟机
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
mvn clean validate compile gwt:compile gcloud:deploy
我还是明白了
java.lang.NoClassDefFoundError: Could not initialize class
com.googlecode.objectify.ObjectifyService
com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:47)
来自 Tomcat 和 Jetty。在我的 target/appengine-staging/WEB-INF/lib/
我有
-rw-r--r-- 1 alex staff 2.2M Dec 25 00:50 guava-18.0.jar
-rw-r--r-- 1 alex staff 474K Dec 25 00:50 hibernate-validator-4.3.2.Final.jar
-rw-r--r-- 1 alex staff 59K Dec 25 00:50 jboss-logging-3.1.0.CR2.jar
-rw-r--r-- 1 alex staff 234K Dec 25 00:50 kotlin-runtime-1.0.0-beta-4584.jar
-rw-r--r-- 1 alex staff 724K Dec 25 00:50 kotlin-stdlib-1.0.0-beta-4584.jar
-rw-r--r-- 1 alex staff 339K Dec 25 00:50 objectify-5.1.9.jar
-rw-r--r-- 1 alex staff 1.8M Dec 25 00:50 requestfactory-server-2.8.0-beta1.jar
-rw-r--r-- 1 alex staff 46K Dec 25 00:50 validation-api-1.0.0.GA.jar
使用
将完全相同的代码部署到 GAE 时工作正常
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
mvn clean package appengine:update
所以这个应用程序在 GAE 上运行良好,cf。 http://epvin.loxal.net
我已将 objectify-5.1.5-sources.jar 添加到我的 WEB-INF\lib
下的 GAE 项目中,并将 web.xml
文件修改为
...
<!-- objectify filter -->
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
...
但是当我部署到 app-engine 时出现以下错误
Uncaught exception from servlet
javax.servlet.UnavailableException: com.googlecode.objectify.ObjectifyFilter
at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:79)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:81)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:199)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:174)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:134)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:527)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:745)
我的 GAE 是 1.9.18
更新:将 jar 更改为 objectify-5.1.5.jar
Uncaught exception from servlet
java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.objectify.ObjectifyService
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:47)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
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.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
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:254)
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:527)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:745)
不要将随机 jar 文件添加到您的项目中。你会让你的问题变得更糟。源 jar 不属于类路径。
您是否完全按照设置说明进行操作?
https://code.google.com/p/objectify-appengine/wiki/Setup
请注意,您还需要 Guava jar。尽管 Maven 很糟糕,但它比手动管理依赖关系要好得多。
如https://code.google.com/p/objectify-appengine/wiki/Setup所述, 我添加了
<filter> <filter-name>ObjectifyFilter</filter-name> <filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class> </filter> <filter-mapping> <filter-name>ObjectifyFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
我的 web.xml
用于 objectify v5.1.9 并使用
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
mvn clean validate compile gwt:compile gcloud:deploy
我还是明白了
java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.objectify.ObjectifyService com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:47)
来自 Tomcat 和 Jetty。在我的 target/appengine-staging/WEB-INF/lib/
我有
-rw-r--r-- 1 alex staff 2.2M Dec 25 00:50 guava-18.0.jar
-rw-r--r-- 1 alex staff 474K Dec 25 00:50 hibernate-validator-4.3.2.Final.jar
-rw-r--r-- 1 alex staff 59K Dec 25 00:50 jboss-logging-3.1.0.CR2.jar
-rw-r--r-- 1 alex staff 234K Dec 25 00:50 kotlin-runtime-1.0.0-beta-4584.jar
-rw-r--r-- 1 alex staff 724K Dec 25 00:50 kotlin-stdlib-1.0.0-beta-4584.jar
-rw-r--r-- 1 alex staff 339K Dec 25 00:50 objectify-5.1.9.jar
-rw-r--r-- 1 alex staff 1.8M Dec 25 00:50 requestfactory-server-2.8.0-beta1.jar
-rw-r--r-- 1 alex staff 46K Dec 25 00:50 validation-api-1.0.0.GA.jar
使用
将完全相同的代码部署到 GAE 时工作正常export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
mvn clean package appengine:update
所以这个应用程序在 GAE 上运行良好,cf。 http://epvin.loxal.net