Mazzy
Mazzy

Reputation: 14189

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

Upvotes: 0

Views: 124

Answers (1)

Terence
Terence

Reputation: 706

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)

Upvotes: 1

Related Questions