how to make tomcat explode the war files

26,041

Solution 1

Your /home/ubuntu/www folder needs to be writable by Tomcat process. The owner and group should be tomcat6/tomcat7 (depending on which TC you use). Like this:

drwxrwxr-x  4 tomcat7 tomcat7 4096 Feb 27 14:08 webapps

You shouldn't chmod 777 the folder, this is a security risk as you correctly surmised. chown tomcat7:tomcat7 should work.

Solution 2

You need to ensure that unpackWARs==true is set.

Set to true if you want web applications that are placed in the appBase directory as web application archive (WAR) files to be unpacked into a corresponding disk directory structure, false to run such web applications directly from a WAR file. WAR files located outside of the Host's appBase will not be expanded.

Source: http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Standard_Implementation

Share:
26,041
kevin
Author by

kevin

Updated on August 24, 2021

Comments

  • kevin
    kevin over 2 years

    With reference to tomcat and extracted files I have configured server.xml to auto deploy : true. My war file name is ROOT.war as I do not want /subdir after the site.com.

    But I dont see the .css .js .java or .class files in /webappts/ROOT or any where. (I have them in the ROOT.war and the site is running fine with reflecting them)

    I only see .class and .java in

    /var/cache/tomcat7/Catalina/localhost/_/org/apache/jsp/
    
    /var/cache/tomcat7/Catalina/localhost/_/WEB-INF/classes/
    

    how to configure tomcat to explode the .war file?

    Update I

    I have Host name="localhost" appBase="/home/ubuntu/www" unpackWARs="true" autoDeploy="true" and I still dont see unpacking . My ROOT.war is in /home/ubuntu/www

    Update II

    One problem I see is that:

    Feb 27, 2013 6:29:02 PM org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive /home/ubuntu/www/ROOT.war
    Feb 27, 2013 6:29:02 PM org.apache.catalina.startup.ContextConfig init
    SEVERE: Exception fixing docBase for context []
    java.io.IOException: Unable to create the directory [/home/ubuntu/www/ROOT]
            at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:100)
            at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:720)
            at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:843)
    

    If i manually make ROOT in /home/ubuntu/www/ with chmod 777 . it gives 404 error (doesnt exists)

  • kevin
    kevin about 11 years
    plus +1 too for valid answer.
  • TrippinBilly
    TrippinBilly about 10 years
    Awesome! This solved my problem. One note, I'm using Tomcat 7 and had to use: sudo chown tomcat:tomcat /var/lib/tomcat7/webapps/