Tomcat not autodeploying war file

浪尽此生 提交于 2019-12-02 17:06:53

Historically, tomcat has never updated the exploded directory when you just drop in a new jar, at least for me. I always assumed this to be a bug, but never looked into it as there is a simple solution. Both of these should work fine:

  • Deploy the war file using the build-in Manager application. Fine if you are ok with using a GUI for production administration. Note This tool used to have issues if you deployed multiple times (again, I never delved into the details), but a Tomcat restart worked fine.
  • Stop, Delete, and Drop. Stop Tomcat, delete the exploded directory, drop in the new war file.
  • Add autoDeploy = true. Works for me

    <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
    

    I usually set the autodeploy in server.xml to false. This allows me to drop the new war and restart tomcat without having to deal with the corresponding directory.

    Yes the exploded directory ought to be updated, however you don't need to stop Tomcat for this to work - it will work with Tomcat running. Can you try it again without stopping Tomcat in between the update?

    Also I use the built-in Manager application which allows me to update war files anywhere in the domain without being root (or apache or whatever tomcat is running as). This is very convenient and can be built into an Ant script.

    In my case i name artifact

    ROOT.WAR
    

    but should be

    ROOT.war
    

    Cheers!

    As I use maven to generate my builds in tomcat inside a ubuntu box, I have a script called

    install_wars.sh

    With the following content:

    mvn clean install
    service tomcat7 stop
    find /var/lib/tomcat7/webapps/ -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \;
    find . -name *.war -exec cp {} /var/lib/tomcat7/webapps/ \;
    service tomcat7 start
    

    You may want to change the path and maven commands accordingly.

    The tomcat stop/start are there to avoid any memory leaks that can make the application slow after several redeploys.

    易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!