gpt4 book ai didi

java.lang.NoClassDefFoundError : com/googlecode/objectify/ObjectifyService 错误

转载 作者:行者123 更新时间:2023-11-30 08:26:17 26 4
gpt4 key购买 nike

我尝试在 Appengine 上运行我的项目,但是当我转到登录页面时,我收到 500 错误和以下堆栈:

    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

我的导入:

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

它说我的 Usercontextlistener 中的第 33 行有问题:

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);

我已经按照下面的建议导入了正确的库,但这并没有解决我的问题。我根本不知道我现在做错了什么。有人可以帮我解决问题吗?感谢您的帮助。

最佳答案

您的项目中需要这些依赖项:

   <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>

关于java.lang.NoClassDefFoundError : com/googlecode/objectify/ObjectifyService 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21628560/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com