jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes Tomcat NoClassDefFoundError resolved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tomcat NoClassDefFoundError resolved" Watch "Tomcat NoClassDefFoundError resolved" New topic

Tomcat NoClassDefFoundError resolved


Joined: Jun 26, 2002
Posts: 2
I'm using Tomcat 4.04 on Win2k and was getting a java.lang.NoClassDefFound error when I try to include and reference classes I created myself that are in the local classpath. This machine is my development workstation, and I really wanted to be able to modify, recompile, and test the classes where they reside without making JARs or moving the classes out of my standard development classpath that is used by servlets and non-servlets.
I searched this newsgroup and found others with the same problem, but no solution that didn't require moving the classes.
My solution is to edit c:\tomcat\bin\setclasspath.bat to include the path of my standard libraries' root. Simple, obvious and effective. Maybe this will help someone else...
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12761
My solution is to use ANT and define a "copy to Tomcat" task. That way if my development classes get really bollixed, Tomcat still works.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60800

I do the same as William. I think it's a bit of a dangerous idea to set the classpath to point all over the place.
Also I'd much rather that my development environment match the production environment as much as possible. Makes for a lot fewer gotchas at deployment time.
Just my way,

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]

Joined: Jun 26, 2002
Posts: 2
Thanks for the feedback. I should point out that I am still learning Java (got to escape the clutches of Microsoft at some point), and none of my code goes into production at this point. For more effective learning, I'm taking quick shortcuts that I agree would not be appropriate in a "real" setting. I'm also just getting into Ant and will implement your suggestion when I get a chance.
Thanks again.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12761
ANT has a steep learning curve but I'll never go back! I use UltraEdit-32 which lets me define projects and project specific Ant tasks.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Please change your name to be compliant with JavaRanch's naming policy. It should not be obviously fictitious.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link: http://aspose.com/file-tools
subject: Tomcat NoClassDefFoundError resolved
Similar Threads
Using CachedRowSet
classpath issue while compiling through cmd prompt
chapter 3 "mini MVC"
Tomcat Servlet/Jsp and CLASSPATH