简体   繁体   中英

NoClassDefFoundError exception in my thread

I get this error:

Exception in thread "http-server" java.lang.NoClassDefFoundError: org/w3c/jigmonitor/ReplyServer

but I don't undestand why. Could someone explain why does this happen?

This is the class that causes the problem:

public class ReplyServer implements Serializable
{
    public ReplyServer()
    {
        super();
    }
}

It looks like the class you're defining isn't being found by something that's trying to load it. In my experience this is caused by one of three problems:

  1. Your package declaration for the class is not correct. In this case something on the http-sever thread is expecting your class to be declared in the package org.w3c.jigmonitor.
  2. Your source file is not located in the correct directory. In this case, your source file should be located in a directory structure like "org/w3c/jigmonitor/", providing that's the package you actually want.
  3. The path of the compiled class for ReplyServer is not in the classpath of your JVM. You can check this by looking at the classpath used to start your JVM and seeing if the class is actually there or not. In most generic setups servlet setups there will be a "WEB-INF/classes" folder for you to go poke around in.

Good luck!

(The link David posted gives a ton of information on this type of issue and the possible causes. I would recommend tucking that away for later)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM