2

I try to run my Project on Appengine, but when i go to the login page i get a 500 error and the following stack:

    2014-02-07 04:37:02.656
Uncaught exception from servlet
java.lang.NoClassDefFoundError: com/googlecode/objectify/ObjectifyService
    at com.appspot.darkening.server.UserContextListener.contextInitialized(UserContextListener.java:33)
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
    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:219)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:194)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:134)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:446)
    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:188)
    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:724)
Caused by: java.lang.ClassNotFoundException: com.googlecode.objectify.ObjectifyService
    at com.google.appengine.runtime.Request.process-6d2a94d1cdc4ec4b(Request.java)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:360)
    at com.appspot.darkening.server.UserContextListener.contextInitialized(UserContextListener.java:33)
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
    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.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:188)
    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)
    ... 1 more

My imports:

import com.appspot.darkening.model.User;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;

It says there is a problem on line 33 in my Usercontextlistener:

public class UserContextListener implements ServletContextListener {
    private static final Logger log = Logger.getLogger(UserContextListener.class.getName());
    private Objectify ofy;

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        // TODO Auto-generated method stub
    }

    @Override

    public void contextInitialized(ServletContextEvent sce) {

     line 33->  Objectify ofy = ObjectifyService.begin(); <-line33
        ObjectifyService.register(User.class);
        User u1 = new User("123", "123", "Test-User", 1);
                //er wordt een dummy objecten aangemaakt
        Date date = new Date();
        User u = new User("admin", "admin", "Overseer", 5); 

        ofy.put(u);
        ofy.put(u1);

I have imported the correct libraries, as suggested below, but it doesn't solve my problem. I simply can't figure out what i'm doing wrong right now. Can anybody help me with what the problem might be? Any help is appreciated.

6 Answers 6

2

You need those dependencies in your project:

   <dependency>
        <groupId>com.googlecode.objectify</groupId>
        <artifactId>objectify</artifactId>
        <version>5.0</version>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>18.0</version>
    </dependency>
Sign up to request clarification or add additional context in comments.

Comments

1

You need to add objectify-N.N.N.jar and guava-N.N.N.jar to your project's WEB-INF\lib directory. Refer to the Setup Wiki on the official Objectify project page.

1 Comment

Thank you for the response. I already had the Objectify.jar in my project. Added the Guava.jar anyway, but i don't use it. Doesn't work yet unfortunately.
0

That the correct objectify jar is not being packaged with your deployment. You will need to figure out why that is, and that will depend on how you are doing deployment (maven, ant, eclipse, intellij, etc). There is not enough information in this question; you're looking at code when you should be looking at packaging and deployment.

Comments

0

Don't forget to add jar's mentioned by Romin to build path in your project.

Comments

0

I was getting the following error.

Uncaught exception from servlet
java.lang.NoClassDefFoundError: com/google/appengine/api/datastore/AsyncDatastoreService
    at com.googlecode.objectify.ObjectifyService.<clinit>(ObjectifyService.java:18)
    at com.isyoudone.dbentity.ClientTokenItem.<clinit>(ClientTokenItem.java:24)
    at com.isyoudone.StoreClientServlet.doGet(StoreClientServlet.java:45)

which is similar to yours. It was accompanied by these kinds of warnings both locally and on the server when I uploaded.

Failed to read file: /base/data/home/apps/s~isyoudone/0.375907684014000310/WEB-INF/lib/appengine-jsr107cache-1.9.4.jar
java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:228)
    at java.util.zip.ZipFile.<init>(ZipFile.java:157)
    at java.util.jar.JarFile.<init>(JarFile.java:153)

turns out that although I was using maven, I had become frustrated with with setting JAVA_HOME to the right version, and had updated Eclipse to use the AppEngine plugin. This had put particular versions of the dependent jar files in

\src\main\webapp\WEB-INF\lib

When I finally got the maven version working, it was using the wrong version of these files, instead of the ones in the maven target directory. Deleting everything in the directory above, solved the problem.

Comments

0

Confirmed that the files need to be in the WEB-INF/lib directory. When I placed the jars in a "UserLibrary" directory below lib, I received the same error. So make sure that the files are indeed in the root level of WEB-INF/lib and you should be good to go.

Comments

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.