• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError when accessing global classes

 
Alan Yap
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've just installed Tomcat 5.5 into "c:\tomcat5.5" folder and been toying around with it the whole day. Tried migrating some of webapps that I did before (and ran quite well in Resin) over to Tomcat, but stumbled upon some errors. I suspect Tomcat might have failed to locate my class files.

This prompts me to start from a clean slate to test it with a new webapp.

I've created a webapp named "mytest", with the following files:

C:\tomcat5.5\webapps\ROOT\WEB-INF\classes\testpack\testobject.class
C:\tomcat5.5\webapps\ROOT\WEB-INF\classes\testpack\testobject.java
c:\mytest\main.jsp (and its content below)



The above throws a NoClassDefFoundError exception. When I moved "testpack\testobject.class" into "c:\mytest\WEB-INF\classes" folder, only then everything is solved.

I have many packages that need to be shared among my webapps, so what is the problem that caused my Tomcat unable to detect them when I put them all inside "C:\tomcat5.5\webapps\ROOT\WEB-INF\classes" ?

Below are the fragments from my CLASSPATH. Anything that I missed out in the configuration?

.;C:\tomcat5.5\common\lib\servlet-api.jar;c:\tomcat5.5\common\lib\jsp-api.jar;

[ September 11, 2008: Message edited by: Alan Yap ]

[ September 11, 2008: Message edited by: Alan Yap ]
[ September 11, 2008: Message edited by: Alan Yap ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Tomcat installation probably has a file named class-loader-howto.html under tomcat-docs.

That file should clarify everything.

Bill
 
Alan Yap
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill!

That howto file you suggested me to read enlightened me alot. My problem is all solved now. I've dunked my class files into "c:\tomcat55\common\classes" and it worked.

Before I started this thread, I was advised by the link below to put all my shared classes into "c:\<tomcat folder>\webapps\ROOT\WEB-INF\classes" folder to conform to the "standard". Doesn't apply to my case though.

http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-5.5.html#Test1
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic