Reputation: 200
I'm trying to deploy a .war project to my tomcat7 installation.
Before copying, I stop the server, copy the war to /var/lib/tomcat7/webapps and then restart the server after it has copied.
When the server starts, the contents are copied out into it's own directory however I get 404 status' when trying to access it from a browser.
Other war files work, and this war file works when used in Eclipse Java EE, so I'm not sure what the problem is.
I'm using Ubuntu 12.04 and Tomcat7.
Upvotes: 1
Views: 3029
Reputation: 48057
Judging from the comments, when you get "permission denied" on temporary files, this IMHO typically shows that you have started tomcat as a different user - commonly this happens when you first start tomcat as root (creating all the temporary files as root) and then as an unprivileged user (who can't overwrite the temporary files).
Technically speaking, when you run as root again, the problems probably disappear, however, this is a security hazard and you should only do this if you want to test the effect. The proper way of doing it is to fix the permissions on temporary files and then never run as root again.
A good way to do this (especially if you run as daemon/service) is to have the startup script automatically set the required owner/permissions on temp, work and log directory (maybe more, you'll have to try) and then assert that tomcat is started as that owner. Starting a daemon is typically done as root, so the startup script probably has the correct permissions to do all of this: chown
, chmod
and su
are your friends here.
A very simple tomcat start script in /etc/init.d/tomcat (on ubuntu) looks like this (user: tomcat, location: /opt/tomcat):
# Tomcat auto-start
#
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $apache2
# Required-Stop: $apache2
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop tomcat server
### END INIT INFO
export JAVA_HOME=/usr/lib/jvm/default-java
cd /opt/tomcat
chown -R tomcat webapps conf temp logs work
case $1 in
start)
sudo -u tomcat /opt/tomcat/bin/startup.sh
;;
stop)
sudo -u tomcat /opt/tomcat/bin/shutdown.sh
;;
restart)
sudo -u tomcat /opt/tomcat/bin/shutdown.sh
sudo -u tomcat /opt/tomcat/bin/startup.sh
;;
esac
exit 0
with this, I can do sudo service tomcat restart
(for example) and don't need to pay attention to the proper permissions any more
Upvotes: 3