[java] Log4j NoClassDefFound Problem

Started by
3 comments, last by steelmtn98 18 years ago
Hey everyone, I've been toying with basic client-server stuff and have tried to use Log4j's Logger for logging server events. However, whenever I try to run the server program from the command line (DOS/Windows), it gives me a NoClassDefFoundException for BasicConfigurator. As far as I know, I correctly added Log4j's .jar to the build path for my project in Eclipse, so I don't see how it can be a classpath issue. I'm not sure, though. Can anyone help? If you need more information, let me know and I'll be happy to give you whatever I can. :) Thanks, Rob
Advertisement
... No one knows? =
- Rob
If you're sure the .jar is in your classpath, then check the version of Log4j you're using. "NoClassDefFoundException" is only thrown when you can find a class, so if you're positive the classpath is right, check if the class is actually packaged with the jar and named as it should be ;)

Son Of Cain
a.k.a javabeats at yahoo.ca
Yes, I looked for it (BasicConfigurator) and it's indeed there. Do you know what else could be a problem?

- Rob
This is a total guess (all my advice is), but maybe it will help...

The log4j.properties file needs to be on your classpath. I usually dump it in a directory called config and add that directory to my classpath.

In Eclipse, press the 'Run' dropdown menu and select the 'Run...' option. A new dialog box will open. Press the Classpath tab under the name of the class you are running. Click on User Entries in the tree. Press the Advanced... button on the left. Select the Add Folders radio button and browse the the new config directory. Now it is on your classpath in Eclipse. Try running the app. Curse or praise my name as appropriate...

Hope this helps, good luck.

This topic is closed to new replies.

Advertisement