Sign in to follow this  
RobAU78

[java] Log4j NoClassDefFound Problem

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this