problem with Tomcat and Ant.....any one help

I use Spring MVC, and in my project , when I use "ant build" command to compile a java file(of course, the target is write in the build.xml which implement the compile task ), the build faied, The command window shows (PS: springapp is my project folder name under webapps):

Buildfile: build.xml

build:

[javac] Compiling 1 source file to C:\Program Files\Apache Software Fo

on\Tomcat 5.5\webapps\springapp\war\WEB-INF\classes

BUILD FAILED

C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\springapp\b

ml:51: C:\Documents and Settings\Chen Xi\Tomcat 5.5\common\lib not found.

But my tomcat is installed in

C:\Program Files\Apache Software Foundation\Tomcat 5.5

And the content of build.properties file is like follows:

# Ant properties for building the springapp

appserver.home=${user.home}/Tomcat 5.5

deploy.path=${appserver.home}/webapps

tomcat.manager.url=http://localhost:8080/manager

tomcat.manager.username=admin

tomcat.manager.password=tomcat

And I know the problem is in build.properties file and build.xml files, for example, in build.properties file, theappserver.home=${user.home}/tomcat 5.5 is wrong, and I correct theappserver.home= value to be my tomcat home directory which is:C:\Program Files\Apache Software Foundation\Tomcat 5.5 , the ant build command still failed to compile the java file, the command window shows now:

BUILD FAILED

C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\springapp\build.xml:51: C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\springapp\Program FilesApache Software FoundationTomcat 5.5\common\lib not found.

How to solve the problem, it seems that inside build.xml, the comipler task can not point to the write location of java file to compile.

by the way, what does the value contain in${user.home} in build.properties file?

[2008 byte] By [Mellona] at [2007-11-26 21:39:50]
# 1
1. You need to have a user.home variable set in your build.properties.2. Its advisable to have folder names without spaces between individual words especially in properties file.ram.
Madathil_Prasada at 2007-7-10 3:23:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

hi! Madathil_Prasad.

I define the user.home in build.properties file, look, it is now like:

# Ant properties for building the springapp

user.home=C:\Program Files\Apache Software Foundation

appserver.home=${user.home}\Tomcat 5.5

deploy.path=${appserver.home}/webapps

tomcat.manager.url=http://localhost:8080/manager

tomcat.manager.username=admin

tomcat.manager.password=tomcat

But when I use "ant build" command to compile the java file, it still failed,

the message show on the command window is:

BUILD FAILED

.......\webapps\springapp\build.xml:51:\ C:\Documents and Settings\Chen Xi Tomcat 5.5\common\lib not found

you see the place I under lined, it can not find the ..\common\lib , that is because it goes to a wrong directory, my tomcat is located in C:\Program Files\Apache Software Foundation\Tomcat 5.5

Not in C:\Documents and Settings\Chen Xi Tomcat 5.5,

why it is like this? where I configure wrong?

why it goes to C:\Document and Setting........Where I should correct this path..... please help. thanks!

by the way, The code in build.xml where I define the compiler target is like follows:

<target name="build" description="Compile main source tree java files">

<mkdir dir="${build.dir}"/>

<javac destdir="${build.dir}" target="1.3" debug="true"deprecation="false" optimize="false" failonerror="true"> <src path="${src.dir}"/>

<classpath refid="master-classpath"/>

</javac>

</target>

The place underlined is where the comand window warining about the error

Message was edited by:

Mellon

Message was edited by:

Mellon

Mellona at 2007-7-10 3:23:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
user.home=C:\Program Files\Apache Software Foundationappserver.home=${user.home}\Tomcat 5.5Change the \'s to /'sMight want to try appserver.home=C:/Program Files/Apache Software Foundation/Tomcat 5.5
benubacha at 2007-7-10 3:23:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Hi,

you said Change the \'s to /'s?but Where?

and I do try appserver.home=C:/Program Files/Apache Software Foundation/Tomcat 5.5

it still does not work.

Again, because I think my "ant build" command go to the wrong pah to find ..tomcat 5.5\common\lib , as you see above, I pasete the command window message.

And in my build.xml, the code I define the compile target is like follows:

......

<fileset dir="${appserver.home}/common/lib">

<include name="servlet*.jar"/>

</fileset>

........

And I define the ${appserver.home}/ in the build.properties file like follows:

user.home=C:\Program Files\Apache Software Foundation

appserver.home=${user.home}\Tomcat 5.5

And, my tomcat is located in C:\Program Files\Apache Software Foundation\Tomcat 5.5

So, please help me, where is wrong that cause the "ant build" command go to c:\Document and Setting\Chen Xi\ tomcat 5.5\common\lib which is not exist, why it does not go to the correct path which is C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib

Please help. THanks.

Message was edited by:

Mellon

Mellona at 2007-7-10 3:23:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

> Hi,

> you said Change the \'s to /'s?but Where?

Wherever you find them.

> And I define the ${appserver.home}/ in the

> build.properties file like follows:

>

> user.home=C:\Program Files\Apache Software

> Foundation

> appserver.home=${user.home}\Tomcat 5.5

There for instance ;-)

Please post the build.xml file to check if the problem is there

And please hurry up, i'm sleepy ;-)

Message was edited by:

benubach

benubacha at 2007-7-10 3:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Hi this is my build.xml, thanks a lot.

<?xml version="1.0"?>

<project name="springapp" basedir="." default="usage">

<property file="build.properties"/>

<property name="src.dir" value="src"/>

<property name="web.dir" value="war"/>

<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>

<property name="name" value="springapp"/>

<path id="master-classpath">

<fileset dir="${web.dir}/WEB-INF/lib">

<include name="*.jar"/>

</fileset>

<!-- We need the servlet API classes:--><!--for Tomcat 4.1 use servlet.jar-->

<!--for Tomcat 5.0 use servlet-api.jar--><!--for Other app server - check the docs -->

<fileset dir="${appserver.home}/common/lib">

<include name="servlet*.jar"/>

</fileset>

<pathelement path="${build.dir}"/>

</path>

<target name="usage">

<echo message=""/>

<echo message="${name} build file"/>

<echo message="--"/>

<echo message=""/>

<echo message="Available targets are:"/>

<echo message=""/>

<echo message="build--> Build the application"/>

<echo message="deploy--> Deploy application as directory"/>

<echo message="deploywar --> Deploy application as a WAR file"/>

<echo message="install--> Install application in Tomcat"/>

<echo message="reload--> Reload application in Tomcat"/>

<echo message="start--> Start Tomcat application"/>

<echo message="stop--> Stop Tomcat application"/>

<echo message="list--> List Tomcat applications"/>

<echo message=""/>

</target>

<target name="build" description="Compile main source tree java files">

<mkdir dir="${build.dir}"/>

<javac destdir="${build.dir}" target="1.3" debug="true"deprecation="false" optimize="false" failonerror="true">

<src path="${src.dir}"/>

<classpath refid="master-classpath"/>

</javac>

</target>

<target name="deploy" depends="build" description="Deploy application">

<copy todir="${deploy.path}/${name}" preservelastmodified="true">

<fileset dir="${web.dir}">

<include name="**/*.*"/>

</fileset>

</copy>

</target>

<target name="deploywar" depends="build" description="Deploy application as a WAR file">

<war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml">

<fileset dir="${web.dir}">

<include name="**/*.*"/>

</fileset>

</war>

<copy todir="${deploy.path}" preservelastmodified="true">

<fileset dir=".">

<include name="*.war"/>

</fileset>

</copy>

</target>

<!-- ============================================================== --><!-- Tomcat tasks - remove these if you don't have Tomcat installed --><!-- ============================================================== -->

<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<taskdef name="list" classname="org.apache.catalina.ant.ListTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<taskdef name="start" classname="org.apache.catalina.ant.StartTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<target name="install" description="Install application in Tomcat">

<install url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" war="${name}"/>

</target>

<target name="reload" description="Reload application in Tomcat">

<reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/>

</target>

<target name="start" description="Start Tomcat application">

<start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/>

</target>

<target name="stop" description="Stop Tomcat application">

<stop url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/>

</target>

<target name="list" description="List Tomcat applications">

<list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"/>

</target>

<!-- End Tomcat tasks -->

</project>

And following is my build.properties file:

# Ant properties for building the springapp

user.home=C:\Program Files\Apache Software Foundation

appserver.home=${user.home}\Tomcat 5.5

deploy.path=${appserver.home}/webapps

tomcat.manager.url=http://localhost:8080/manager

tomcat.manager.username=admin

tomcat.manager.password=tomcat

Message was edited by:

Mellon

Mellona at 2007-7-10 3:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

<fileset dir="${appserver.home}/common/lib">

<include name="servlet*.jar"/>

</fileset>

The problem lies there. Please, change ${appserver.home} to the directory that contains the tomcat installation directly on that line:

<fileset dir="C:/Program Files/Apache Software Foundation/Tomcat 5.5/common/lib">

<include name="servlet*.jar"/>

</fileset>

Run man! It's 3 am here ;-)

Edit 3: (I know it belongs below but...) run

ant -verbose build

That will show you a lot more of what ant is doing.

Edit: And don't use \ as path separator. Always use /

Ant already knows if you're on window$ or UN*X ;-)

Edit 2: If that DOES work, change the build.properties to

# Ant properties for building the springapp

user.home=C:/Program Files/Apache Software Foundation

appserver.home=${user.home}/Tomcat 5.5

deploy.path=${appserver.home}/webapps

tomcat.manager.url=http://localhost:8080/manager

tomcat.manager.username=admin

tomcat.manager.password=tomcat

Message was edited by:

benubach

Message was edited by:

benubach

Message was edited by:

benubach

benubacha at 2007-7-10 3:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Hi! benubach ... Thank you so much!!! It works now.Sorry to keep you awake at 03:00 AM.I may have more problems in future, I wish to keep contact with you. Thank you all replied.
Mellona at 2007-7-10 3:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Hey man, no problem :-) That's why I come here ;-)Anytime. My email is benubach at gmail Send me a message and we may chat or something :-) (That does NOT goes for everyone here, ok? :-p)
benubacha at 2007-7-10 3:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10
Thanks,thanks.It is really nice to know you:)
Mellona at 2007-7-10 3:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11

HI everyone.

I have a problem trying to build the same application , though i renamed it SpringParoquia. Im getting started with this so it would be nice if any of you could help.

Im trying to build it from eclipse and i get this error:

Buildfile: C:\Programas\Apache Software Foundation\Tomcat 6.0\webapps\SpringParoquia\build.xml

usage:

[echo] SpringParoquia build file

[echo] --

[echo] Available targets are:

[echo] build--> Build the application

[echo] deploy--> Deploy application as directory

[echo] deploywar --> Deploy application as a WAR file

[echo] install--> Install application in Tomcat

[echo] reload--> Reload application in Tomcat

[echo] start--> Start Tomcat application

[echo] stop--> Stop Tomcat application

[echo] list--> List Tomcat applications

build:

build:

deploy:

build:

deploywar:

install:

BUILD FAILED

C:\Programas\Apache Software Foundation\Tomcat 6.0\webapps\SpringParoquia\build.xml:109: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/install?path=%2FSpringParoquia&war=SpringParoquia

Total time: 1 second

i renamed the dir to SpringParoquia and here's the buildfile:

<?xml version="1.0"?>

<project name="SpringParoquia" basedir="." default="usage">

<property file="build.properties"/>

<property name="src.dir" value="src"/>

<property name="web.dir" value="war"/>

<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>

<property name="name" value="SpringParoquia"/>

<path id="master-classpath">

<fileset dir="${web.dir}/WEB-INF/lib">

<include name="*.jar"/>

</fileset>

<!-- We need the servlet API classes:-->

<!--for Tomcat 4.1 use servlet.jar-->

<!--for Tomcat 5.0 use servlet-api.jar-->

<!--for Other app server - check the docs -->

<fileset dir="${appserver.home}/common/lib">

<include name="servlet*.jar"/>

</fileset>

<pathelement path="${build.dir}"/>

</path>

<target name="usage">

<echo message=""/>

<echo message="${name} build file"/>

<echo message="--"/>

<echo message=""/>

<echo message="Available targets are:"/>

<echo message=""/>

<echo message="build--> Build the application"/>

<echo message="deploy--> Deploy application as directory"/>

<echo message="deploywar --> Deploy application as a WAR file"/>

<echo message="install--> Install application in Tomcat"/>

<echo message="reload--> Reload application in Tomcat"/>

<echo message="start--> Start Tomcat application"/>

<echo message="stop--> Stop Tomcat application"/>

<echo message="list--> List Tomcat applications"/>

<echo message=""/>

</target>

<target name="build" description="Compile main source tree java files">

<mkdir dir="${build.dir}"/>

<javac destdir="${build.dir}" target="1.3" debug="true"

deprecation="false" optimize="false" failonerror="true">

<src path="${src.dir}"/>

<classpath refid="master-classpath"/>

</javac>

</target>

<target name="deploy" depends="build" description="Deploy application">

<copy todir="${deploy.path}/${name}" preservelastmodified="true">

<fileset dir="${web.dir}">

<include name="**/*.*"/>

</fileset>

</copy>

</target>

<target name="deploywar" depends="build" description="Deploy application as a WAR file">

<war destfile="${name}.war"

webxml="${web.dir}/WEB-INF/web.xml">

<fileset dir="${web.dir}">

<include name="**/*.*"/>

</fileset>

</war>

<copy todir="${deploy.path}" preservelastmodified="true">

<fileset dir=".">

<include name="*.war"/>

</fileset>

</copy>

</target>

<!-- ============================================================== -->

<!-- Tomcat tasks - remove these if you don't have Tomcat installed -->

<!-- ============================================================== -->

<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<taskdef name="list" classname="org.apache.catalina.ant.ListTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<taskdef name="start" classname="org.apache.catalina.ant.StartTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">

<classpath>

<path location="${appserver.home}/server/lib/catalina-ant.jar"/>

</classpath>

</taskdef>

<target name="install" description="Install application in Tomcat">

<install url="${tomcat.manager.url}"

username="${tomcat.manager.username}"

password="${tomcat.manager.password}"

path="/${name}"

war="${name}"/>

</target>

<target name="reload" description="Reload application in Tomcat">

<reload url="${tomcat.manager.url}"

username="${tomcat.manager.username}"

password="${tomcat.manager.password}"

path="/${name}"/>

</target>

<target name="start" description="Start Tomcat application">

<start url="${tomcat.manager.url}"

username="${tomcat.manager.username}"

password="${tomcat.manager.password}"

path="/${name}"/>

</target>

<target name="stop" description="Stop Tomcat application">

<stop url="${tomcat.manager.url}"

username="${tomcat.manager.username}"

password="${tomcat.manager.password}"

path="/${name}"/>

</target>

<target name="list" description="List Tomcat applications">

<list url="${tomcat.manager.url}"

username="${tomcat.manager.username}"

password="${tomcat.manager.password}"/>

</target>

<!-- End Tomcat tasks -->

</project>

also i get warnings on eclipse on the taskdef elements that say :

taskdef class org.apache.catalina.ant.StartTask cannot be found

Thank You

sh3ltera at 2007-7-10 3:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...