1)It clearly meant that Tomcat has not loaded its jar servlet-api.jar into the classpath & why is it happening & what can be done to rectify this
2) Since I've ant I want to use Ant to separate source from the generated class files. How to use that. If i have the package structure com.common.java; then the class files should be in webinf/classes/com/common/java/WebTest.class How this can be achieved using Ant. Remember ant is in my path.
where you placed your servlet-api.jar . better to place in tomcat/common/lib
ramya narayanan
Ranch Hand
Joined: Oct 06, 2008
Posts: 338
posted
0
The server was started using startup.bat This is the document trace which i got when I run the server I ran the server by
Server trace:
Now when i compile, by appending the jar manually to the classpath it's working.
1)Why we should manually append the jar to the classpath doesn't Tomcat does it of its own
2) How to use Ant here to separate java from class files. Regards.
ramya narayanan
Ranch Hand
Joined: Oct 06, 2008
Posts: 338
posted
0
Dear seetharaman venkatasamy, My servlet-api.jar is only in CATALINA_HOME\common\lib. Where CATALINA_HOME is pointing to E:\apache-tomcat-5.5.27 Regards.
1)It clearly meant that Tomcat has not loaded its jar servlet-api.jar into the classpath & why is it happening
Because here you are compiling the source files which has nothing to do with the tomcat (It's JAVA compiler you are using ). By the way it's really a bad practice to put the source files & compiling from inside the Application server.
Keep your development environment out of application server. When you want to deploy you may create a WAR or move the necessary files to the application server.
If i have the package structure com.common.java; then the class files should be in webinf/classes/com/common/java/WebTest.class How this can be achieved using Ant.
You have to use Ant's javac Task with srcdir and destdir attributes. Have a look at the manual for complete information.
Does the Tomcat Manager (usually at http://localhost:8080/manager/html/list) list the application as running? [ December 23, 2008: Message edited by: Ulf Dittmer ]
By the way it's really a bad practice to put the source files & compiling from inside the Application server.
I'm very eager to know why is it so? Because inside the application, i'm separating the source & class files right.
Because here you are compiling the source files which has nothing to do with the tomcat (It's JAVA compiler you are using )
But i'm using some dependencies ( some classes of servlet-api.jar) in my source file(WebTest.java) which directly access the tomcat dependencies only right.
You have to use Ant's javac Task with srcdir and destdir attributes. Have a look at the manual for complete information.
Certainly & thanks for the links. Regards.
ramya narayanan
Ranch Hand
Joined: Oct 06, 2008
Posts: 338
posted
0
Doesn't Tomcat load all of its jars inside common\lib to classpath when we start the server . I have JAVA_HOME & also CATALINA_HOME defined properly, which is echoed when the server is started up.(Please see my second post) Regards.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35254
7
posted
0
Doesn't Tomcat load all of its jars inside common\lib to classpath when we start the server.
Yes it does, but as was said above, Tomcat has nothing to do with the Java compiler. And compiling servlets has no dependency on Tomcat - rather it depends on the jar file that contains the Servlet API. Tomcat just happens to include this jar file, that's all.
ramya narayanan
Ranch Hand
Joined: Oct 06, 2008
Posts: 338
posted
0
Understood ! When we are compiling, we are compiling with the java compiler javac, which as of such doesn't know about servlet-api.jar or any other jars, which has to be directed using javac -classpath. Then what is the use of Tomcat loading all the jars at the time of starting the server? Regards.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35254
7
posted
0
How could Tomcat function if it didn't have the servlet API and all those other jar files?
ramya narayanan
Ranch Hand
Joined: Oct 06, 2008
Posts: 338
posted
0
For what function does Tomcat is loading these jars like servlet-api.jar & other jars in the classpath. Regards.
ramya narayanan
Ranch Hand
Joined: Oct 06, 2008
Posts: 338
posted
0
Any replies?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35254
7
posted
0
Once again:
Originally posted by Ulf Dittmer: How could Tomcat function if it didn't have the servlet API and all those other jar files available?
If you're curious what's inside of these jars, you can use "java -tf foobar.jar" to see all the classes. And if you're really curious how it all works, well, it's open source, so the source code is available for study.