Tomcat paths in Ubuntu 12.10

And so I have the displeasure of working with Java — a platform I once swear to avoid for the rest of my life — and I had to have my Ubuntu 12.10 environment set up. This is also verified to be similar in Ubuntu 12.04.

If you install tomcat7 from the official repository using “sudo apt-get install tomcat7”, the following paths and commands are probably helpful to you too.

Your WAR files

WAR files (.war) typically go into:

[code language=”bash”]/var/lib/tomcat7/webapps[/code]

Your log files

Your log files should be here:

[code language=”bash”]/var/lib/tomcat7/logs[/code]

It should be called “catalina.out”. It’s useful to check here for troubleshoot Apache Tomcat. It doesn’t mean that tomcat’s successful start would mean the application to be working. catalina.out has saved me on several occasions.

Your tomcat7 configuration files

Server settings goes here:

[code language=”bash”]/etc/tomcat7/server.xml[/code]

You might find the other properties files useful as well:

[code language=”bash”]/etc/tomcat7[/code]

Your tomcat7 and catalina startup shell files

You might need to edit some .sh files like in my case to change Catalina options. You can find the shell scripts here:

[code language=”bash”]/usr/share/tomcat7/bin[/code]

You can read more on setting up Catalina environment options.

Other notes

If you know of other paths worth including, do post a comment. While this is documented more for personal use, I hope you can find it useful too!

How to set Catalina options in Ubuntu 12.10

This is more of a personal note and a really specific topic. This tutorial assumes you are using Ubuntu 12.10 or Ubuntu 12.04 and installed tomcat7 package. If you haven’t already installed tomcat7, use:

[code language=”bash”]sudo apt-get install tomcat7[/code]

After doing so, create and edit the file Putting in CATALINA_BASE/bin allows you to keep your customizations separate.

[code language=”bash”]sudo nano /usr/share/tomcat7/bin/[/code]

I set my environment variables (in my case) as in

[code language=”bash”]
CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m"

If the file is present, will pick it up and add to the runtime parameters.

To restart tomcat7, use:

[code language=”bash”]sudo service tomcat7 restart[/code]

Verifying that it works

After the server restart, run this to check:

[code language=”bash”]ps aux|grep jar[/code]

This should return:

[code language=”bash”]tomcat7 14140 63.8 11.4 4001076 918296 ? Sl 12:26 1:37 /usr/lib/jvm/default-java/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/ -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 org.apache.catalina.startup.Bootstrap start
kahwee 15564 0.0 0.0 13580 936 pts/1 S+ 12:29 0:00 grep jar[/code]

You should be able spot your line of customization. And that’s the proper way to setting up Catalina options. You can also set JAVA_OPTS through this method too.