Skip to content

Tomcat config with sakai

by Ammar on October 15, 2011

I’ve been struggling with setting up tomcat with sakai over the last few days. I’ve learned that although tomcat is relatively easy to set up, there are still quite a few hoops you have to jump through.

Installing tomcat itself is pretty straightforward, simply download the version you want, unzip the file and there you have it, your tomcat server. It needs minimal configuration – you can change the port it runs on in conf/server.xml (though beware, you need to be root to run anything on a port below 1000-something) and there are database settings somewhere in server.xml. Before you try running the server, make sure the environment variable $JAVA_HOME is set to the base of your java installation! For me this was at /usr/lib/jvm/java-6-sun, though it could very well be different depends on how your system is set up. The next thing to do is create an /etc/init.d script to make it much easier to start and stop – I took mine from howtogeek. Then, if you chmod u+x the script in init.d, you can just do service tomcat start to start the service.

The biggest problem I ran into was exceeding the limit for the number of open files. By default on Ubuntu, you’re only allowed a little over a 1000 open files at a time. For running a tomcat server which could open many many thousands of files itself, this is nowhere near enough, and for the longest time I couldn’t figure out why the server kept failing to load. It was only after tailing the log file using tail -f /opt/tomcat/logs/catalina.out and catching the ‘too many files open’ error that flew by that I realized that I was running out of the file limit. You can check your file hard and soft limits by running ulimit -Hn and ulimit -Sn. To modify this limit, you need to edit /etc/security/limits.conf and add the following two lines: * soft nofile 65536 and * hard nofile 65536 which sets the max number of open files (nofiles) limit to 65536. You might have to do a restart after this.

Once you have this down, however, tomcat should just work, and you’ll be able to access your webapp at localhost:8080 or whatever port you specified. Yay.

From → Tech

No comments yet

Leave a Reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS

Spam prevention powered by Akismet