Search code examples
javajsptomcatservletstomcat7

how to make tomcat explode the war files


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)


Solution

  • 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.