Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Anyone try to put java classes file into Tomcat ever?

 
james
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing a test for servlet in using Tomcat4.0.1.
What I did is put a HelloServlet.class file into the following directory,
<tomcat home>webapps\ROOT\WEB-INF\Classes\, then invoke the servlet: http://localhost:8080/servlet/HelloServlet. Based on the tutorial, this processedure should be right. But I failed to invoke HelloServlet.class.
But if I put the class file into: <tomcat home>\classes\, I can get correct response from the servlet.
Do you know the reason?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be related the fact that if you don't put your servlet classes in a package, Tomcat looks in it's "current" directory.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18276
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you really did name the class directory "Classes", that could be the problem. Java very frequently requires upper/lower case distinctions be maintained in filenames even in OS's like Windows that otherwise don't care. The proper name of the directory is "classes" (all lower-case), and for certain any other capitalization will break the "write-once/run-anywhere" capabilities of the web app, since Unix system filenames ARE case senstive.
It doesn't help any that when you create a folder with the Windows GUI, it very helpfully wants to uppercase the first character.
 
james
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks, I solved the problem! I downloaded a zip file then unzip it into my c:\ directory instead of downloading a exe file then install it. This is interesting issue, might be a bug in Tomcat4.0 distribution. After installation, I created /classes directory under /webapps/ROOT/WEB-INF, then put .class file into it, it works.
Tim Holloway:
You are right, it cannot be /Classes, it should be /classes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic