Tomcat's CLASSPATH is different than Java's, and it does not include “.” How do I change it?

Classes required in a web application should be located within the web application in the WEB-INF/classes folder or packed in JAR files located in WEB-INF/lib. You should normally not use the servlet containers generic classpath settings for this, as you seem to attempt.

All my servlets are in WEB-INF/classes/controllers, and the classes i'm trying to load are *. Class files in subdirectories. My issue is that since "." doesn't appear to be in my web app's classpath, loading libraries from subdirectories does not work.

– Murat Ayfer Oct 23 '09 at 12:00 2 The correct package for a class file located in WEB-INF/classes/controllers/packagename/ClassName. Class would be "controllers. Packagename" and not "packagename" as your question seem to imply.

You cannot have additional subdirectories below WEB-INF/classes as class path roots and the system properties or environment variables are in a web application not evaluated by the class loader as they are in a standalone appplication. – jarnbjo Oct 23 '09 at 12:23 1 . Would likely refer to the startup script of tomcat, not the webapp.

– nos Nov 6 '09 at 19:38.

Tomcat's classpath is not supposed to be starting with .. Actually, adding . To the classpath is just a convenient way to tell java to look for classes in the current directory without having to use -cp when using it on the command line. Actually, in most case, you don't have to tweak Tomcat's URL1 make Tomcat able to find your classes, what you need to do is to deploy your application as a standardized WAR (web archive) which has a specific layout.

Something like that: . |-- WEB-INF | |-- classes | | `-- com | | `-- mycompany | | `-- MyServlet. Class | |-- lib | | |-- bar.

Jar | | `-- foo. Jar | `-- web. Xml |-- application.

Jsp |-- image. Gif `-- index. Html The WEB-INF/classes directory is where your compiled classes need to be, this is where Tomcat will look for them.

If you place your classes in WEB-INF/classes/controllers, controllers will be considered as part of the package name (which is likely not what you want). So you have two options: remove that controllers directory or add it to the package name. But they are mutually exclusive, you can't have both.

CLASSPATH is not "supposed" to start with ". ". Since its purpose is configuration of the runtime, it is free to take on any value you choose.

Also note that using the CLASSPATH environment variable has been discouraged since Java 1.1 (released in early 1997)—at least 12 years. The classpath of a web-application, on the other hand is well-specified. Move the contents of the controllers directory (and any other invalid subdirectories) into WEB-INF/classes/, so that the package directory is an immediate child of classes.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions