GAE application using Objectify 5.1.21 started throwing NoClassDefFoundError

288 views
Skip to first unread message

Tim Martens

unread,
Mar 26, 2018, 12:37:18 PM3/26/18
to objectify-appengine
We have a GAE application that has been using Objectify for well over a year.  On Friday we did a minor release that changed a few POJOs unrelated to Objectify usage and everything stopped working.  Any ideas on why it would suddenly stop working when we've changed nothing about our deploy?

Here is the stacktrace:

018-03-24 06:10:39.460 PDT
Uncaught exception from servlet
java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.objectify.ObjectifyService
at net.plantango.OfyService.init(OfyService.java:48)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:643)
at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:422)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1406)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1368)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:522)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:244)
at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:182)
at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:97)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:680)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:642)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:612)
at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run(JavaRuntime.java:806)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:274)
at java.lang.Thread.run(Thread.java:745)

This is the code for the OfyService class

public class OfyService extends GenericServlet
{
private static final long serialVersionUID = 1L;

public void init()
throws ServletException
{
//Availability List API
ObjectifyService.register(AvailabilityList.class);
       
        //Inventory API
ObjectifyService.register(Site.class);
ObjectifyService.register(Location.class);
ObjectifyService.register(Item.class);
ObjectifyService.register(ItemType.class);
ObjectifyService.register(Product.class);
ObjectifyService.register(Size.class);
ObjectifyService.register(SpacingMethod.class);
ObjectifyService.register(CropStage.class);
ObjectifyService.register(DumpReason.class);
ObjectifyService.register(InventoryGcmRegistration.class);
       
        //Plant API
ObjectifyService.register(Pest.class);
ObjectifyService.register(Disease.class);
ObjectifyService.register(PruneMethod.class);
ObjectifyService.register(PruneType.class);
ObjectifyService.register(Chemical.class);
ObjectifyService.register(BioAgent.class);
ObjectifyService.register(Fertilizer.class);
ObjectifyService.register(PlantGcmRegistration.class);
       
        //Common API
ObjectifyService.register(Department.class);
ObjectifyService.register(CommonGcmRegistration.class);
       
        //Shipping API
ObjectifyService.register(ShippingContainer.class);
ObjectifyService.register(ShippingGcmRegistration.class);

//Session API
ObjectifyService.register(PlantangoUser.class);
ObjectifyService.register(SessionGcmRegistration.class);
}

public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException
{

}

public static Objectify ofy()
    {
        return ObjectifyService.ofy();
    }

    public static ObjectifyFactory factory()
    {
        return ObjectifyService.factory();
    }
}


Jeff Schnitzer

unread,
Mar 26, 2018, 12:59:18 PM3/26/18
to objectify-appengine
NoClassDefFoundError means there is a problem with your classpath. Somehow the objectify jar isn’t being seen, or maybe there is an extra old version on the classpath, etc.

The answer is somewhere in your build system, not your code. Check there.

Suerte,
Jeff

--
You received this message because you are subscribed to the Google Groups "objectify-appengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectify-appengine+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Martens

unread,
Mar 26, 2018, 2:16:56 PM3/26/18
to objectify-appengine
I was mistaken with the stacktrace, the one I provided happens for all calls after the initial call.  This is the very first stacktrace:

2018-03-26 11:04:52.752 PDTUncaught exception from servlet java.lang.NoClassDefFoundError: com/google/appengine/api/datastore/AsyncDatastoreService at com.googlecode.objectify.ObjectifyService.<clinit>(ObjectifyService.java:20) at net.plantango.OfyService.init(OfyService.java:48) at javax.servlet.GenericServlet.init(GenericServlet.java:244) at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:643) at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:422) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1406) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1368) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:522) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:244) at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:182) at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:97) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:680) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:642) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:612) at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run(JavaRuntime.java:806) at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:274) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: com.google.appengine.api.datastore.AsyncDatastoreService at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at com.google.apphosting.runtime.ApplicationClassLoader.findClass(ApplicationClassLoader.java:45) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 22 more

I see in the Android Studio Setup 2.0 here (https://github.com/objectify/objectify/wiki/Setup) that it mentions this error.  However, I'm using Eclipse and Maven.  I'm also using endpoints-framework v2.  This is what I have in my pom.xml:

<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>2.0.9</version>
</dependency>

Tim Martens

unread,
Mar 26, 2018, 2:17:40 PM3/26/18
to objectify-appengine
Better formatting of the stack trace:

2018-03-26 11:04:52.752 PDT
Uncaught exception from servlet

Tim Martens

unread,
Mar 26, 2018, 2:27:38 PM3/26/18
to objectify-appengine
Got this figured out.  Posting so if anyone else runs into this.  The problem was in the com.google.appengine maven dependency.

    <dependency>
      <groupId>com.google.appengine</groupId>
      <artifactId>appengine-api-1.0-sdk</artifactId>
      <version>1.9.63</version>
    </dependency>

I had <scope>provided</scope> in there.

Jeff Schnitzer

unread,
Mar 26, 2018, 2:28:24 PM3/26/18
to objectify-appengine
Heh, yeah don’t do that!!

Jeff

--
Reply all
Reply to author
Forward
0 new messages