views:

737

answers:

2

I'm very new to Tomcat and I'm having some issues figuring out how to set it up. I set it up on Ubuntu Linux and started reading and trying to follow the information given on the apache website here: http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html

Apparently I'm missing something. I have a WAR named MyWebapp.war and it's in a directory /home/mywebapp. In /etc/tomcat6/Catalina/localhost/MyWebapp.xml, I have the following line:

<Context path="/MyWebapp" docBase="/home/mywebapp" antiResourceLocking="false" />

Everything else is the default configuration that came with tomcat6 via the Ubuntu package. When I restart Tomcat and try to go to http://localhost:8080/MyWebapp, I get a 404. The WAR file isn't unpacked and nothing seems to be working.

I'm going to be deploying two Grails applications on this server with Tomcat.

Is there a more straight forward way to do this?

+2  A: 

I find the most straightforward way to deploy a .war to Tomcat is to use the Manager Webapp.

All you need to do is follow the instructions linked above. Setup a user in the default memory realm $CATALINA_BASE/conf/tomcat-users.xml. Navigate to http://myserver:8080/, log in with that user, deploy your app point-and-click style. Very handy, especially when you're getting started with Tomcat.

It also means you can deploy a war from your desktop, without having to manually copy it to the server.

Without using the manager webapp, you should be able to copy your war to $CATALINA_HOME/webapps and it should be automatically deployed for you. You shouldn't have to manually configure a Context for your app unless your app needs something like connection pooling resources setting up.

Brabster
+1  A: 

If you installed the packaged version, then the default webapp location is:

/var/lib/tomcat6/webapps

This location belongs to the tomcat6 user (you can use a symlink to your war if you want).

BTW, I don't know if what you're trying to do is possible but the current context configuration won't work. You're basically telling Tomcat that /home/mywebapp is a webapp (which is not the case), Tomcat will not look for a .war in there.

Actually, my recommendation would be to download a vanilla Tomcat archive, to unzip it somewhere in your home directory (I use ~/opt) to install it and.. that's all.

Then to start Tomcat, just run:

$ ~/opt/apache-tomcat-6.0.26/bin$ ./startup.sh 

To deploy a war, just copy it to:

~/opt/apache-tomcat-6.0.26/webapp
Pascal Thivent
I saw that and I put my war in that directory and restarted tomcat. While it does unpack my war, I still can't seem to get to it through a web browser...
intargc
What URL do you try to access?
Pascal Thivent
http://localhost:8080/MyWebapp
intargc
What is the war file name?
Scott Warren
@intargc check the logs (in /var/log/tomcat6/catalina.out I think).
Pascal Thivent
Yep, I was about to say, I checked the logs and was getting some exceptions about java.security.AccessControlException: access denied (java.util.PropertyPermission grails.env read). I realized that in /etc/default/tomcat6 there is an option TOMCAT6_SECURITY. I set that to no, restarted tomcat and the application works.Thanks!
intargc