Monday, November 27, 2006

java.lang.NoClassDefFoundError: org/apache/commons/

I'm working on a project where I needed to make HTTP requests. Instead of reinventing the wheel, I decided to use Apache-Commons-Httpclient library. Upon compiling, the code blew up in my face. The debugger says:

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

Hmm... so Apache-Commons-Httpclient is dependent upon Apache-Commons-Logging library. After I download and add the required library, I compile the code to have it blow up in my face again. This time the debugger says:

java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException

Good god, another dependency. This time Apache-Commons-Codec. That's what I hate about external libraries. None of them is self contained. I need the code small enough to fit in embedded devices like a cell phone. Good thing Apache-Commons library is opensource, so the source code is available. I need to strip it down. So much for reinventing the wheel.

2 comments:

Anonymous said...

I've got the same problem. Thanks very much.
Bye
HernĂ¡n from Argentina

Ravi said...

awesome! good find.. thanks..
you should probably link those jar to your post.