views:

144

answers:

1

I'm following a tutorial to set up a skeleton application for tomcat :

http://maestric.com/doc/java/spring/setup#build_files

But I don't understand how build.properties and build.xml actually works.

I'm using windows XP and copied the following even though the required directory doesn't exist:

appserver.home=/usr/share/tomcat5.5
appserver.lib=${appserver.home}/common/lib

Really confused now:(

+1  A: 

Tomcat doesn't use the build.xml and the build.properties files, these are for Ant which is a tool to automate the build of the application. The script shown in this tutorial is pretty basic, it defines 2 targets to compile sources and to clean compiled classes. And you would use them like this:

ant build

or

ant clean

The appserver.lib property is used to build the class path required to compile sources. It is derived from the root of your Tomcat installation directory and is used to find the JAR for the Servlet API that you need to compile sources. If you decide to use this Ant script, you should update the appserver.home property to match your install. For example:

appserver.home=c:/apps/tomcat5.5
appserver.lib=${appserver.home}/common/lib

But to be honest, the whole setup is a bit messy (it's straightforward, but messy):

  1. you shouldn't bundle the servlet-api.jar in WEB-INF/lib as suggested
  2. I don't like to develop directly under Tomcat's webapp directory (but this is maybe subjective).
Pascal Thivent
Seems there is no `${appserver.home}/common/lib` in tomcat6 any more?
symfony
@symfony for Tomcat 6, use `${appserver.home}/lib` instead (this is where you'll find `servlet-api.jar`).
Pascal Thivent
Is this why you said "1.you shouldn't bundle the servlet-api.jar in WEB-INF/lib "?Because it's already available for tomcat?
symfony
@symfony Because the specifications says so (the Servlet API jar is indeed provide by containers, Tomcat in your case).
Pascal Thivent
Did you try spring mvc in eclipse?I found it's necessary to have servlet-api.jar in WEB-INF/lib,otherwise eclipse will report a Java Build Path Problem
symfony
@symfony Yes, servlet-api.jar has to be on the classpath during compilation but no, you shouldn't put it in WEB-INF/lib (other containers than Tomcat may complain about this spec violation).
Pascal Thivent
Oh,got it.BTW,do you mean that tomcat isn't the only choice to server `.jsp`?
symfony