I have been developing an application on Tomcat and things are running smooth. However, for demonstration purposes I have to deploy the application using Ant. For development purposes I manually created a folder in "webapps" of tomcat and manually created all the other folders. The name of the root directory is quizz and the directory structure is as follows:
In Tomcat's root directory, webapps, I have my application root directory "quizz". In quizz I have all of my jsp's, images folder(with images), css folder(style sheets) and another folder called WEB-INF.
In WEB-INF I have a web.xml file and two other folders, a "classes" folder and a "lib" folder. As usual the classes folder stores all my java .class files and .java files. This structures works fine on Tomcat and I was able to develop my application which worked fine. However for the purposes of using ant I had to use another directory structures and copied all the necessary files in a different directory structure. This structures is as follows. In a folder called package that resides on my desktop I have the "build.xml" and three other folders. Those folders are:
src, web and meta-data.
The web folder has all the presentation files, .jsp's, images folder, css folder. The src folder has all the java .class files. And the meta-data folder has the web.xml file. When I run "ant" it is supposed to place everything neatly and nicely on tomcat for me so that I can just re-start the server and run. I get a successful build but the app does not work. I get a HTTP status 404 error stating the requested resource is not available. Here is what my build.xml looks like.
The ant places a different directory structure in "webapps". It generates a war file with the app name and a folder with the app name. The folder has a WEB-INF folder and a META-INF folder. Can some one help. I hope my explanation was not long winded.
It looks like the 'package' target will include only the classes and web.xml files. You need to include the JSPs and other files that are in your web folder, but I don't see anything for that in the script.
Here is what I usually do for packaging a WAR: I create a directory for the WAR, usually named xxx.war (where xxx is my app name), and then have Ant copy all of the files for the WAR into that directory. This way I can visual verify that my exploded WAR directory contains all the files that I need. Then I usually use the <jar> task to create the WAR, but using the <war> task will work as well. I tell the <jar> task to package the entire xxx.war directory. I then have the option of copying either the xxx.war file, or the xxx.war directory (renaming it to just xxx) to Tomcat's webapps directory.
I have solved the problem and I wish to thank everyone's input. Here is the code for the modified build.xml. All I did was place the WEB-INF(along with its usual contents, web.xml, classes folder etc) into the web folder and used the copy function to dump it into the root package folder. This is what it looks like:
Of course since the "src" folder has all my classes I have to copy everything from "compile" destination folder to the "WEB-INF/classes" folder.
Happily living in the valley of the dried frogs with a few tiny ads.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth