这是我的监听器类,用于注册我的用户实体。注册我的POJO类时发生错误。但是,我的应用程序在本地环境中工作正常。部署到App Engine后,我收到服务器错误500.
@WebListener
public class MyContextListener implements ServletContextListener {
public void contextDestroyed(ServletContextEvent sce) {}
public void contextInitialized(ServletContextEvent sce) {
ObjectifyService.register(User.class);
}
}
以下是我的完整堆栈跟踪
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)
答案 0 :(得分:1)
看起来您正在尝试自己管理依赖项,而不是依赖于pom中的依赖项信息。通过stackoverflow调试类路径问题很难。
我建议使用maven和appengine maven插件。使用Google的入门指南获取项目,然后添加Objectify。
答案 1 :(得分:0)
可能这段代码可以帮助你
try {
Class.forName("com.googlecode.objectify.ObjectifyService");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
此代码用于初始化此类的对象
此代码首先尝试在继续之前加载上述类。