Objectify OfyService NoClassDefFoundError for the endpoint of the application engine

My android-appengine-endpoint project is fully customizable to android studio. Therefore, I don’t communicate with anyone: I’ll just let android studio add my AppEngine module to my Android project. Now I get java.lang.NoClassDefFoundError. Should I install something in gradle or configure somethings in android studio to get rid of this error? Basically, when I try to test my application, I get an exception.

code:

Note. Instead of calling ofyinside my endpoint class, UserDao is the place where all data access calls are made ofy. You can compare my code with this tutorial.

public class UserDao extends OfyService {
    public static void persist(User user) {
        ofy().save().entities(user).now();
    }
    public static User getById(long id) {
        return ofy().load().type(User.class).id(id).now();
    }
    public static List<User> getByTwitterId(Long twitterId) {
        return ofy().load().type(User.class).filter("twitterId", twitterId).list();
    }
}

public class OfyService {
    public OfyService() {}

    static {
        ObjectifyService.register(User.class);
        ObjectifyService.register(Food.class);
        ObjectifyService.register(Pet.class);
    }

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

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

Actual error visible from the App Engine console:

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backed method
java.lang.NoClassDefFoundError: Could not initialize class com.mycompany.server.data.dao.UserDao
    at com.mycompany.server.utils.Authenticator.verifyAccount(Authenticator.java:22)
    at com.mycompany.server.endpoint.server.getFood(server.java:105)
    at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:44)
    at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
    at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
    at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    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 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 org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    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:230)
    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 java.lang.Thread.run(Thread.java:745)

, , , WEB-INF\lib. Android Studio - lib WEB-INF. , Android Studio App Engine Google. .

webapp/WEB-INF :

  • web.xml
  • logging.properties
  • appengine-web.xml

, :

enter image description here

+4
2

Cloud Endpoint, :

  • Endpoint .
  • new OfyService().

, , , , , ( , ). , . App-Engine . , , , , : , . . . ( ) , . :).

+2

, Objectify .

,

  • ( User, Food, Pet);
  • OfyService ( ).
+1

Source: https://habr.com/ru/post/1611161/


All Articles