Am Mittwoch, den 08.08.2007, 11:40 +0800 schrieb Jeff.Yu:
> 2. Deploy to Container
> --------------------------------
> It will be different from what we have now, I would like to pack all the
> required jars to $WAR/WEB-INF/lib folder, and then generate a WAR, so if
> you want to deploy it to containers, what you need to do is to copy the
> WAR to the container's deploy folder. you can see details in this
> thread:
> http://www.nabble.com/How-to-deploy-to-JBoss--tf4210975.html#a11978522
>
Excellent!!!
> For tomcat container, if you set the CATALINA_HOME, and then you run:
> "ant deploy-tomcat" , it will copy the generated war to the
> $CATALINA_HOME/webapps/
>
Great! But if that *doesn't* work (I can't recall how well it works
with overwriting existing WAR files) you can use the Tomcat manager
tasks, something like the following:
<property name="catalina.ant.jar"
value="${webserver.home}/server/lib/catalina-ant.jar"/>
<target name="deploy-on-tomcat" depends="war">
<taskdef name="deploy-to-tomcat"
classname="org.apache.catalina.ant.DeployTask">
<classpath>
<pathelement location="${catalina.ant.jar}"/>
</classpath>
</taskdef>
<taskdef name="undeploy"
classname="org.apache.catalina.ant.UndeployTask">
<classpath>
<pathelement location="${catalina.ant.jar}"/>
</classpath>
</taskdef>
<undeploy url="${tcManagerURL}" username="${tcUsername}"
password="${tcPassword}"
path="/${war.app.name}" failOnError="false"
/>
<deploy url="${tcManagerURL}" username="${tcUsername}"
password="${tcPassword}"
path="/${war.app.name}"
war="${basedir}${file.separator}${war.app.name}.war"
/>
</target>
Note I'm putting the taskdef's *within* the target instead of outside of
it--that prevents the build.xml file from trying to find
catalina-ant.jar (and failing) if you are using another app server.
This way, only if you explicitly call deploy-to-tomcat does it try to
find those jars.
Note if we go this route (which I recommend only if WAR copying and
overwriting doesn't work), the user needs to alter tomcat-users.xml to
add a "manager" role, and locate the catalina-ant.jar file to make sure
it is part of the classpath.
Regards,
Glen