1

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

3
  • Please check in your build path, might be you have added two different jar's having class with same name. Commented Mar 23, 2018 at 12:30
  • How to check if two different jars have class with same name? Commented Mar 23, 2018 at 13:20
  • Are you using maven ? Commented Mar 26, 2018 at 5:07

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

2 Comments

Now I get the following error in the line Class.forName() java.lang.NoClassDefFoundError: com/google/appengine/api/datastore/AsyncDatastoreService
Your application is unable to load these classes by self so you have to load all classes manually by using the above snip.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.