2

I have added objectify-5.1.5-sources.jar to my GAE project under WEB-INF\lib and I have modified the web.xml file as

...
<!-- 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>
...

But when I deploy to app-engine I get the following error

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)

My GAE is 1.9.18

update: more of error trace after changing jar to 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)
Alex
  • 8,245
  • 8
  • 46
  • 55
Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199
  • The sources are useful for developing purpopes, but for the runtime are not necessary. Are you added to your classpath the JAR package instead of the sources? – Deviling Master Apr 05 '15 at 18:26
  • @DevilingMaster I tried a few things before coming back. But the binary jar didn't help. It just changed the error message to `java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.objectify.ObjectifyService ...` – Katedral Pillon Apr 05 '15 at 19:28
  • just to be on the safe side, I also tried adding all four jars: `objectify-5.1.5`, `objectify-gwt-1.2.1`,`objectify-insight-1.0.3`, and `objectify-remotely-0.8`. But still nothing. – Katedral Pillon Apr 05 '15 at 20:54
  • 1
    have you added guava? Thats a dependency defined by Objectify – jirungaray Apr 06 '15 at 04:21
  • Did you solve this in the end? I'm having the same error with Maven and only with the uploaded app. – Vitali Pom May 09 '15 at 16:36

2 Answers2

0

Do not add random jar files to your project. You will make your problem worse. Source jars do not belong on the classpath.

Have you followed the setup directions exactly?

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

Note that you need the Guava jar as well. As horrible as Maven is, it's a lot better than managing dependencies by hand.

stickfigure
  • 13,458
  • 5
  • 34
  • 50
-1

As described in https://code.google.com/p/objectify-appengine/wiki/Setup, I’ve added

<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>

to my web.xml for objectify v5.1.9 and deploy my to a VM using

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
mvn clean validate compile gwt:compile gcloud:deploy

Still I get

java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.objectify.ObjectifyService com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:47)

from both Tomcat and Jetty. In my target/appengine-staging/WEB-INF/lib/ I’ve got

-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

The very same code works fine when deploying it to GAE with

export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
mvn clean package appengine:update

So this app runs fine on GAE, cf. http://epvin.loxal.net

And here is the code https://github.com/loxal/Epvin

Alex
  • 8,245
  • 8
  • 46
  • 55