This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat NoClassDefFoundError resolved

 
mlweber
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
bear
 
mlweber
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mlweber,
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.
Thanks,
Cindy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic