简体   繁体   English

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

[英]java.lang.NoClassDefFoundError: com/googlecode/objectify/ObjectifyService

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: 我尝试在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

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: 它说我的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);

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. 任何帮助表示赞赏。

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>

You need to add objectify-NNNjar and guava-NNNjar to your project's WEB-INF\\lib directory. 您需要将objectify-NNNjarguava-NNNjar到项目的WEB-INF\\lib目录中。 Refer to the Setup Wiki on the official Objectify project page. 请参考官方Objectify项目页面上的Setup Wiki。

That the correct objectify jar is not being packaged with your deployment. 正确的对象化jar没有与您的部署打包在一起。 You will need to figure out why that is, and that will depend on how you are doing deployment (maven, ant, eclipse, intellij, etc). 您将需要弄清楚原因,这取决于您进行部署的方式(maven,ant,eclipse,intellij等)。 There is not enough information in this question; 这个问题没有足够的信息。 you're looking at code when you should be looking at packaging and deployment. 当您应该查看打包和部署时,您正在查看代码。

不要忘记添加Romin提到的jar来在项目中构建路径。

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. 事实证明,尽管我使用的是maven,但我对将JAVA_HOME设置为正确的版本感到沮丧,并更新了Eclipse以使用AppEngine插件。 This had put particular versions of the dependent jar files in 这已将特定版本的依赖jar文件放入

\\src\\main\\webapp\\WEB-INF\\lib \\ SRC \\主\\ web应用\\ 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. 当我终于使maven版本工作时,它使用的是这些文件的错误版本,而不是maven目标目录中的文件。 Deleting everything in the directory above, solved the problem. 删除上面目录中的所有内容,即可解决问题。

Confirmed that the files need to be in the WEB-INF/lib directory. 确认文件需要在WEB-INF / lib目录中。 When I placed the jars in a "UserLibrary" directory below lib, I received the same error. 当将罐子放在lib下方的“ UserLibrary”目录中时,我收到了相同的错误。 So make sure that the files are indeed in the root level of WEB-INF/lib and you should be good to go. 因此,请确保文件确实在WEB-INF / lib的根目录下,并且您应该一切顺利。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError:com / googlecode / concurrentlinkedhashmap / ConcurrentLinkedHashMap $ Builder - java.lang.NoClassDefFoundError: com/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap$Builder java.lang.NoClassDefFoundError:无法初始化com.googlecode.luceneappengine.GaeDirectory类 - java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.luceneappengine.GaeDirectory 将Objectify与GAE一起使用时,ObjectifyService的NoClassDefFoundError - NoClassDefFoundError for ObjectifyService when using Objectify with GAE java.lang.NoClassDefFoundError:com / sun / star / lang / XEventListener - java.lang.NoClassDefFoundError: com/sun/star/lang/XEventListener java.lang.NoClassDefFoundError:com.google.android.gms.gcm.GoogleCloudMessaging使用java.lang.NoClassDefFoundError: - java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging using java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError - java.lang.NoClassDefFoundError java.lang.NoClassDefFoundError - java.lang.NoClassDefFoundError “ java.lang.NoClassDefFoundError” - “java.lang.NoClassDefFoundError” java.lang.NoClassDefFoundError - java.lang.NoClassDefFoundError java.lang.NoClassDefFoundError - java.lang.NoClassDefFoundError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM