Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Folder issues with Tomcat 7 on Ubuntu

Tags:

ubuntu

tomcat

I've installed Tomcat 7 on Ubuntu 14.04. The main problem is with two different folders which are sometimes redundant:

/usr/share/tomcat7

drwxrwxrwx 2 root root 4096 dic 15  2013 backup
drwxrwxrwx 2 root root 4096 set  3 13:28 bin
lrwxrwxrwx 1 root root   21 nov 17  2013 conf -> /var/lib/tomcat7/conf
-rwxrwxrwx 1 root root   39 feb 21  2014 defaults.md5sum
-rwxrwxrwx 1 root root 2030 feb 21  2014 defaults.template
drwxrwxrwx 2 root root 4096 set  3 13:28 lib
lrwxrwxrwx 1 root root   16 nov 17  2013 log -> /var/log/tomcat7
-rwxrwxrwx 1 root root   53 feb 21  2014 logrotate.md5sum
-rwxrwxrwx 1 root root  118 feb 21  2014 logrotate.template
drwxrwxrwx 2 root root 4096 dic  2 13:00 logs
drwxrwxrwx 3 root root 4096 dic  6 17:33 webapps
drwxrwxrwx 3 root root 4096 dic 15  2013 work
drwxrwxrwx 5 root root 4096 dic  2 13:16 wtpwebapps

/var/lib/tomcat7

drwxr-xr-x 3 tomcat7 tomcat7 4096 nov 16  2013 common
lrwxrwxrwx 1 root    root      12 mag 24  2013 conf -> /etc/tomcat7
lrwxrwxrwx 1 root    root      17 mag 24  2013 logs -> ../../log/tomcat7
drwxr-xr-x 3 tomcat7 tomcat7 4096 nov 16  2013 server
drwxr-xr-x 3 tomcat7 tomcat7 4096 nov 16  2013 shared
drwxrwxr-x 4 tomcat7 tomcat7 4096 dic  6 23:51 webapps
lrwxrwxrwx 1 root    root      19 mag 24  2013 work -> ../../cache/tomcat7

When I installed packages such as tomcat7-docs, tomcat7-examples and tomcat7-admins, they were automatically deployed under /usr/share/tomcat7/webapps. Also Eclipse, when the option "Use Tomcat installation" is selected, automatically deploys the files under /usr/share/tomcat7/wtpwebapps.

However, if I have to deploy a web app of mine, I've to put it under /var/lib/tomcat7/webapps; I don't know if it is right, maybe yes, but why? Also, when I look at the log files generated when launching my web apps, tomcat complains about some folders that do not exists; indeed, they exists only under /var/lib/tomcat7 and not under /usr/share/tomcat7.

Dec 06, 2014 11:50:23 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
Dec 06, 2014 11:50:23 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
Dec 06, 2014 11:50:23 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Dec 06, 2014 11:50:23 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
Dec 06, 2014 11:50:23 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Dec 06, 2014 11:50:23 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]

So, what I've to change to make all works? Is this folder structure desiderable?

like image 386
tigerjack Avatar asked Dec 06 '14 23:12

tigerjack


1 Answers

Those 2 directories are used by tomcat to allow configuration of multiple tomcat instances all using a single installation directory but each having its own directories for deployment, logs, conf, etc.

Tomcat uses the following environment variables (or system properties) to specify the 2 directory locations:

CATALINA_HOME (catalina.home), the tomcat install directory and
CATALINA_BASE (catalina.base), the base directory for a tomcat instance

Some tomcat installations use the same directory for both catalina.base and catalina.home and that's the default behavior if CATALINA_BASE is not set.

Given the Ubuntu 14.04 tomcat7 configuraion of:

catalina.home=/usr/share/tomcat7
catalina.base=/var/lib/tomcat7

You should deploy applications to /var/lib/tomcat7/webapps. The only time apps should be deployed to $CATALINA_HOME/webapps is if catalina.base=catalina.home. Installation of tomcat7 on my Ubuntu 14.04 didn't even create a /usr/share/tocmat7/webapps.

The reason I found your post is that I recently installed tomcat7 and encountered the same "Problem with directory" warnings that you are getting:

WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]

The warning are the result the common.loader, server.loader, and shared.loader entires in $CATALINA_BASE/conf/catalina.properties. As they should be, the common, server, and shared directories are under $CATALINA_BASE.

I eliminated the warnings by changing each *.loader= entry to use catalina.base rather than catalina.home for those directories (6 places).

like image 192
rstoko Avatar answered Sep 23 '22 10:09

rstoko