shri cool
shri cool

Reputation: 95

java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.objectify.ObjectifyService

This is my Listener Class which registers my User Entity. The error occurs while registering my POJO class. However, my application works fine in local environment. After deploying to App Engine, I get Server error 500.

@WebListener
public class MyContextListener implements ServletContextListener {

         public void contextDestroyed(ServletContextEvent sce)  {}

         public void contextInitialized(ServletContextEvent sce)  { 
                 ObjectifyService.register(User.class);
          }
    }

Below is my complete stack trace

java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.objectify.ObjectifyService
at com.appengine.listener.MyContextListener.contextInitialized (MyContextListener.java:23)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized (ContextHandler.java:843)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized (ServletContextHandler.java:533)
at org.eclipse.jetty.server.handler.ContextHandler.startContext (ContextHandler.java:816)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:345)
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)

The JAR files added in my application My JARS

Upvotes: 1

Views: 2190

Answers (2)

stickfigure
stickfigure

Reputation: 13556

Looks like you're trying to manage dependencies yourself instead of relying on dependency information in the pom. It's hard to debug classpath issues over stackoverflow.

I suggest using maven and the appengine maven plugin. Get a project working using the Google's getting started guide and then add Objectify.

Upvotes: 1

Chirag
Chirag

Reputation: 565

May be this piece of code help you

try {
    Class.forName("com.googlecode.objectify.ObjectifyService");
} catch (ClassNotFoundException e) {
    e.printStackTrace();
}

This code where you are initializing the object of this class

This code first tries to load the above class before going ahead.

Upvotes: 0

Related Questions