I have a development folder that contains all my auxilliary classes. In my application's classes directory I have all the classes that are specific to this single project.
I am extending a class in my /WEB-INF/classes directory tree that extends a class in my development directory that extends HttpServlet the only purpose for the class in the classes directory is to extend the other class since a servlet has to be in the classes directory, it adds no extra functionality.
My problem is this, it seems that the class in the auxilliary folder cannot 'see' the javax.servlet.http package, since I get not able to create HttpServlet instance error when I access it through Tomcat. The classes are already compiled. ( From my local machine with a network drive pointing to the server ) Is there some reason that classes outside the WEB-INF folder would not be able to instantiate even if they are already compiled?
I thought the container would follow the CLASSPATH environmental variable to locate classes. If not, is there a directory within tomcat that is classes can be put in such that they are available across contexts or is this bad design?
Joined: Oct 29, 2003
Let me set this up a little better:
Dev dir. c:\classes
Catalina Docbase c:\classes\webapps\appname
Servlets in c:\classes\webapps\appname\WEB-INF\classes are accessible and can read classes in c:\classes, the problem is when I try to use classes that extend, or otherwise use, javax.servlet.http classes. I have already compiled the classes but I get the following error from Tomcat when I use them in a servlet.
Tomcat pays no attention whatsoever to the CLASSPATH environment variable.
Classes specific to the web app should be placed under the WEB-INF/classes folder (make sure that all classes belong to a package other than the default).
If the classes are in a jar file, the jar file should be placed in the web app's WEB-INF/lib folder.
Classes to be shared across multiple web app should be jarred up and the jar file placed in $TOMCAT_HOME/shared/lib.
Note that there's a difference between building the web app and deploying the web app. You can build anywhere you want to, but the classes must adhere to the above pattern for Tomcat to construct its run-time classpath.