Tomcat with Gentoo

Well, running Tomcat with Gentoo is somewhat ugly. First of all, after installing Tomcat and running it, there was no page at all. So after making sure, that Tomcat is actually running, and that there isn’t any other application listening on that port (e.g. Apache2), I went to the web and found out that I’d need to have the “examples” Useflag. Tried that, no change. So I ran an “emerge –newuse”, but even after that, it didn’t work.

It then came to my mind to look into the $CATALINA_HOME/webapps path. This is when I figured, that Tomcat on Gentoo has a totally different setup. Gentoo tries to install all applications in compliance to the FHS. Now the normal way to install Tomcat would be to download it, and decompress it at /opt. This complies with FHS as /opt should be used to install optional/additional software packages. Still, to put everything into /opt/tomcat/* would be wrong – instead all the other files like /var/log for the logging files, or /usr/share for all the architecture independent files, etc.

Still, Gentoo doesn’t comply to the FHS a 100%. E.g. it doesn’t use the /srv for the server files. They are even not in /var/www but in /var/lib/tomcat/webapps. Now you wouldn’t call a Webapplication a library file, would you?

So actually, though it is a good idea, the result is a bit disappointing.

So here is where to find what:

Tomcat Gentoo What to find here?
/opt/tomcat/bin /usr/share/tomcat/bin The binaries to start and stop tomcat. Scripts for this task will be installed into /etc/init.d/ by Gentoo.
/opt/tomcat/conf /etc/tomcat The configuration files.
/opt/tomcat/logs /var/log/tomcat/ Here you’ll find the log-files
/opt/tomcat/temp /var/tmp/tomcat Temporary files
/opt/tomcat/webapps /var/lib/tomcat/webapps In here all web-applications should go
/opt/tomcat/work /var/run/tomcat This is the path in which all sources and classes go

To access this folders, Gentoo introduces a lot of system variables, that point to the different directories (e.g. CATALINA_HOME, CATALINA_USER, CATALINA_BASE, CATALINA_LIBDIR, …)

Now, if you have such a table available, it’s quite easy to follow any tutorial, or to find the stuff you need. Still, when I looked into /var/lib/tomcat/webapps/ROOT, I found it empty, also a path /var/lib/tomcat/webapps/examples wasn’t there. I finally found all my files in /usr/share/tomcat/webapps. Of course, tomcat doesn’t look into this directory – so it’s not available. I don’t get why this directory is at a totally wrong place. Copying it to the proper directory will allow you to access the standard data. Still, the ROOT path doesn’t exist at all. I finally helped myself by getting the current tomcat, extracting it, and copying the webapps directory. Now this works perfectly.

I’m now taking into consideration of moving webapps to /srv, because to me that makes more sense.

Still, sometimes Gentoo sucks…

Btw. the examples folder in /usr/share/tomcat/webapps/examples just includes the subdirectories. When you actually descent to e.g., you’ll find yourself watching at a 404 error page. Seems like this Tomcat package is totally f*cked up…


One thought on “Tomcat with Gentoo

  1. /var/lib is different than /usr/lib so it isn’t a library in that sense. /opt is usually reserved for packages that don’t use the native system installer or have closed licenses.

    If you deploy your web apps/.wars to /var/lib/tomcat6/webapps you ought to be fine. I think this is documented officially on Fedora uses the same directory as well.

    Of course, by changing the config file you can use /srv/ for all your vhosts. I like it that way because then I can define my own /srv/ directory structure and let the default install stuff get clobbered w/o worry.

Please comment. I really enjoy your thoughts!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s