Raible's Wiki
Raible Designs AppFuseHomepage- Korean - Chinese - Italian - Japanese QuickStart Guide User Guide Tutorials Other ApplicationsStruts ResumeSecurity Example Struts Menu
Set your name in
UserPreferences
Referenced by
JSPWiki v2.2.33
Hide Menu |
This is version 14.
It is not the current version, and thus it cannot be edited. I've been told I should use Tomcat's Ant Tasks (install, list, refresh, remove) in AppFuse to ease deployment of the app. So I tried that today (June 24, 2003). Here's how I set it up and what I found. I hope to use this page to get a consensus on how these tasks should be used. 1. First, I defined a tomcat.classpath for the catalina-ant.jar file. Putting in in $ANT_HOME/lib did not work - and this way seemed cleaner. So in properties.xml, I added: <!-- For Tomcat Tasks --> <path id="tomcat.classpath"> <fileset dir="${tomcat.home}/server/lib" includes="catalina-ant.jar" /> </path>2. Then in build.xml, I define the tasks in the "define-tasks" target: <!-- Tomcat Tasks --> <taskdef name="install" classname="org.apache.catalina.ant.InstallTask" classpathref="tomcat.classpath" /> <taskdef name="list" classname="org.apache.catalina.ant.ListTask" classpathref="tomcat.classpath" /> <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask" classpathref="tomcat.classpath" /> <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask" classpathref="tomcat.classpath" />3. Then I created targets for each one of these tasks: <!-- =================================================================== --> <!-- install, list, reload and remove are all Tomcat deployment targets. --> <!-- =================================================================== --> <target name="install" depends="package-web" description="Install application to servlet container"> <install url="${tomcat.manager.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${webapp.name}" war="file://${webapp.dist}/${webapp.war}"/> </target> <target name="list" depends="define-tasks" description="List installed applications on servlet container"> <list url="${tomcat.manager.url}" username="${tomcat.username}" password="${tomcat.password}" /> </target> <target name="refresh" depends="package-web" description="Reload application on servlet container"> <reload url="${tomcat.manager.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${webapp.name}"/> </target> <target name="remove" depends="define-tasks" description="Remove application on servlet container"> <remove url="${tomcat.manager.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${webapp.name}"/> </target>NOTE: I used "refresh" as a target name since I already have a "reload" task that stops tomcat, undeploys, cleans and redeploys. 4. My understanding is that I should be able to point the install and refresh tasks at the .war file for my app, and it'll install/reload as requested. The list and remove tasks work fine at this point. My Issues:Install: Doesn't work. I get the good ol' java.sql.SQLException: Cannot load JDBC driver class 'null'. Everything looks fine from the Ant side though:[install] OK - Installed application at context path /appfuseIf I restart Tomcat, everything starts and loads just fine. Remove: Doesn't seem to work, but it actually does. Here's what Ant reports: [remove] FAIL - Encountered exception java.io.IOException: java.lang.NullPointerExceptionIf I run the same task again, I get: [remove] FAIL - No context exists for path /appfuseProving that it actually did work the first time. Reload: Doesn't work: [reload] FAIL - Reload not supported on WAR deployed at path /appfuseEven though my context has reloadable="true" My Thoughts
CommentsInstall: Doesn't work.: Well, you need to specify the context XML file also (it's a separate deployment, so the existing one doesn't get picked up automatically). If the Context element is in server.xml, then it won't work. Remove: Doesn't seem to work: I don't know about that one. Probably the fact that there a context file is causing trouble of some sort. Reload: Doesn't work: You can't reload a WAR indeed (you undeploy it, and then redeploy it when it is updated; however, its content cannot change unless the WAR itself changes, that's why reloading has no meaning for a WAR). Webapp reloading is for automatic class change tracking. It doesn't prevent any manual reloading. The behavior of the deployer and its related tasks will be more intuitive in TC 5, and more integrated with the auto deployer. the latest nightly has a lot of this stuff implemented http://cvs.apache.org/builds/jakarta-tomcat-5/nightly/jakarta-tomcat-5-bin-20030624.tar.gz. Note that both install and remove are now deprecated, replaced by deploy and undeploy. ~ Remy ~ CorrectionsComments and suggestions are not quite correct.I have not changed earlier contributions - instead I have added some coding samples that really work. Newer distributions (Tomcat4.1.24, Tomcat4.1.27) document in detail the usage of the ant tasks, see Manager_App_HOW-TO in the tomcat-docs. <!-- Install war file to servlet container --> <target name="install"> <install url="${managerapp.url}" username="${managerapp.userid}" password="${managerapp.password}" path="/${context}" war="jar:file:${build.dir}/${war.file}!/" /> </target>On the other hand, the deploy target uses a simple file-URL: <!-- Deploy an application to servlet container --> <target name="deploy"> <deploy url="${managerapp.url}" username="${managerapp.userid}" password="${managerapp.password}" path="/${context}" war="file:${build.dir}/${war.file}" /> </target>Other targets that do not require a war attribute are uncritical, eg <!-- Remove an application on servlet container --> <target name="remove"> <remove url="${managerapp.url}" username="${managerapp.userid}" password="${managerapp.password}" path="/${context}" /> </target>There is one remaining problem with the undeploy target - in some circumstances the target does not complete but ends up with an error message: <!-- Undeploy an application from servlet container --> <target name="undeploy"> <undeploy url="${managerapp.url}" username="${managerapp.userid}" password="${managerapp.password}" path="/${CONTEXT}" /> </target> FAIL - Cannot remove document base for path /eai_scThe reason seems to be some locking by the Tomcat server itself. While Tomcat is running, even a remove (rm -rf under Unix) doesn´t work. As a workaround you can also use the remove task to withdraw the deployment of your webapp. ~ Martin Wolf ~ Attachments:
|