Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 850
kevin Avatar asked Feb 27 '13 13:02

kevin


People also ask

Does Tomcat unpack WAR files?

Java web applications are usually packaged as WAR files for deployment. These files can be created on the command line or with an IDE, like Eclipse. After deploying the WAR file, Tomcat unpacks it and stores all the project files from the webapps directory in a new directory named after the project.

Can we deploy WAR file in Tomcat?

Perhaps the simplest way to deploy a WAR file to Tomcat is to copy the file to Tomcat's webapps directory. Copy and paste WAR files into Tomcat's webapps directory to deploy them. Tomcat monitors this webapps directory for changes, and if it finds a new file there, it will attempt to deploy it.

Why my WAR file is not deployed in Tomcat?

Try stopping Tomcat, deleting the war and matching folder, copying the new war in, then starting Tomcat. If it works then, the problem might be left over files. (I have an app for example that doesn't completely clean itself up). (3) The app might not be initializing properly due to issues with the app.


2 Answers

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.

like image 178
rootkit Avatar answered Sep 17 '22 06:09

rootkit


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

like image 38
Marcel Stör Avatar answered Sep 18 '22 06:09

Marcel Stör