posted 13 years ago
The standard Tomcat distribution is suitable for being run either as a private user process or as a system process. Normally, when you want to run as a private user, you keep a copy of the whole Tomcat server in one of your own private directories.
/usr/local is a place to put system-wide resources. Files and directories under it are normally owned by system users. Frequently, that user is "root", but some installs might have created a user named "tomcat" or something like that. The important thing, however, is that private users are not generally granted write access to resources under /usr/local.
In fact, in a "proper" world, /usr/local files are all read-only, but that's a convention that's often ignored. The RPM-based Tomcat installers get around that by replacing the writable parts of Tomcat with links to alternative locations such as /usr/local/tomcat/work -> /tmp/tomcat. Debian-style installers tend to be less elaborate, so you may or may not see that in Ubuntu, and, of course, if Tomcat was simply unzipped into /usr/local, the only way that will happen is if you do it yourself.
But regardless, if you run tomcat using sudo TOMCAT_HOME/catalina.sh or one of its friends (such as startup.sh), that is going to cause certain files to be created owned by the root user. Once you do that, you'll have problems starting/stopping Tomcat as a non-root user, whether it's as a non-sudo user command-line start/stop or via the system "service" command if the initscript is set up to run Tomcat as user "tomcat".
The fix is to sudo remove the root-owned writable files: "rm -rf TOMCAT_HOME/work/* TOMCAT_HOME/log/* TOMCAT_HOME/temp". You may need to change access rights on files in conf/Catalina/localhost as well.
Once you've done that, be consistent in how you start/stop tomcat.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.