File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes classes directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "classes directory" Watch "classes directory" New topic
Author

classes directory

Amber Woods
Ranch Hand

Joined: Mar 28, 2001
Posts: 111
I am using webappcabaret to learn servlets and I have created some servlets successfully when I place them directly under my context name in the directory WEB-INF/classes but when I try to put servlets in a directory under classes it won't work.
For example I created a TestServlet that just prints out a message and type this in the address bar: www.webappcabaret.com/amberw/servlet/Test.TestServlet. The error that I got was this:
Error: 500
Location: /amberw/servlet/Test.TestServlet
Internal Servlet Error:
java.lang.NoClassDefFoundError: Test/TestServlet (wrong name: TestServlet)
...plus a bunch more junk
I don't know what I am doing wrong. I am not sure if I need to put something in web.xml or not.
Any Help is appreciated
Thanks - Amber


"Happiness is a way to Travel, <b>Not</b> a Destination" -- Unknown
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

Amber:
From what I understand using hints from the terms Test.TestServlet, you have a package structure for your
TestServlet.
Hence you should not put your class file in the WEB-INF/classes
folder. You need to create a Test folder under classes and then
copy your TestServlet.class file into the newly created Test folder.
Correct me if I am wrong, meaning if you don't have a package structure in your TestServlet.
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Amber Woods
Ranch Hand

Joined: Mar 28, 2001
Posts: 111
No, Satya, I don't have TestServlet as part of a package but if that is the way to get it to work I will make it part of a package.
All I really want to do is be able to keep my class files separate and neat. I have two servlets with the same name but different contents (for an assignment). I just wanted to keep them separate (putting them in different folders under classes directory) instead of having to rewrite over the previous version any time I wanted to see if that servlet works correctly.
This is something like where my files are:
WEB-INF/classes/Test/TestServlet.class
WEB-INF/classes/Test2/TestServlet.class
and the TestServlet.class files are different. The way I called them in the location bar has been like this:
www.webappcabaret.com/amberw/servlet/Test.TestServlet www.webappcabaret.com/amberw/servlet/Test/TestServlet www.webappcabaret.com/amberw/servlet/TestServlet www.webappcabaret.com/amberw/servlet/Test2.TestServlet www.webappcabaret.com/amberw/servlet/Test2/TestServlet
and none of them work but maybe I will try to put them in a package. I just thought it would be something else.
Thanks - Amber
[This message has been edited by Amber Woods (edited June 26, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: classes directory