dhoward (1) [Avatar] Offline
#1
I'm brand-new to Ant, and using your book to figure out how to write a script to build and deploy (from/to my local machine) a very simple JSP app in a WAR with just three beans and three .jsp files. I'm using Ant 1.6.2, Tomcat 5.0.28 and Eclipse 3.0.1 on Mac OS X 10.3.5, in case it matters.

My script has three targets: one to create the WAR file within my project, one to delete the old WAR file and expanded directory from the Tomcat webapps folder, and one to install the WAR file from my project into Tomcat's webapps folder. The first two targets work perfectly. The third one is the reason for my writing.

What's happening is that the WAR does get installed, but I nevertheless get a very ominous message from the build.

The target looks like this:

<!-- Deploy the new war file -->
<target name="deploy-war" depends="create-war,remove-war">
<copy file="${project.dir}/${webapp.name}.war" toDir="${install.dir}"/>
<get src="${deploy.install.url}?path=/${webapp.name}&war=jar:http://localhost:8080/webapps/${webapp.name}.war!/" >
dest="deploy.txt"
username="${catalina.username}"
password="${catalina.password}"/>
<loadfile property="deploy.result" srcFile="deploy.txt"/>
<echo>${deploy.result}</echo>
</target>

The output looks like this:

deploy-war:
[copy] Copying 1 file to /Library/Tomcat/webapps
[get] Getting: http://localhost:8080/manager/install?path=/jsp-sample&war=jar:http://localhost:8080/webapps/jsp-sample.war!/
[echo] FAIL - Encountered exception java.lang.IllegalArgumentException: Invalid URL for web application archive: http://localhost:8080/webapps/jsp-sample.war

Can someone help me understand what's wrong? The URL looks fine to me, and as I said, the WAR does get installed. I cannot deliver this with such an ominous message, though.

Thanks--

Denise
ErikHatcher (211) [Avatar] Offline
#2
Re: Problem/question related to Chapter 7.5
Denise - it would be more helpful for you to bring this issue to the Ant user e-mail list. This forum is for Java Development with Ant specific discussions on errata and book questions.

Someone can probably help you on the list in a matter of minutes, whereas it would be a while before I can set up an environment to troubleshoot this myself.
steve_l (100) [Avatar] Offline
#3
Re: Problem/question related to Chapter 7.5
Looking at it, it looks to me like a tomcat message that we got sent back. I've never seen it before.

A quick google for the error message shows up in the javadocs for tomcat:

+ * @exception IllegalArgumentException if the specified context path
+ * is already attached to an existing web application.

So: if the webapp is already deployed, it throws an exception. Since it is already deployed, everythign still works, but be careful that the updates go through.