使用带有GAE的Objectify时,ObjectifyService的NoClassDefFoundError

时间:2015-04-05 16:26:05

标签: java google-app-engine lucene objectify google-eclipse-plugin

我已将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$1.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$1.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)

2 个答案:

答案 0 :(得分:0)

不要将随机jar文件添加到项目中。你会让你的问题变得更糟。源jar不属于类路径。

您是否完全按照设置说明进行操作?

https://code.google.com/p/objectify-appengine/wiki/Setup

请注意,您还需要番石榴罐。像Maven一样可怕,它比手工管理依赖项要好得多。

答案 1 :(得分:-1)

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进行客观化v5.1.9并使用

将我部署到虚拟机
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
mvn clean validate compile gwt:compile gcloud:deploy

我还是

  

java.lang.NoClassDefFoundError:无法初始化类   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上运行正常,参见http://epvin.loxal.net

这是代码https://github.com/loxal/Epvin