开发者

Tomcat is installed with CATALINA_HOME in /usr/share/tomcat6 and CATALINA_BASE in /var/lib/tomcat6

开发者 https://www.devze.com 2023-01-10 18:10 出处:网络
I think it is a good question. I found it also confusing. I installed tomcat few minutes ago (after a while) and I notice they are two different \"webapps\" places.

I think it is a good question.

I found it also confusing. I installed tomcat few minutes ago (after a while) and I notice they are two different "webapps" places.

at /usr/share/tomcat6/webapps/default_root/ at /var/lib/tomcat6/webapps/ROOT/

The content of both are the same but none of them are symlinks.

When I started tomcat it says:

Quote:

This is the default Tomcat home page. It can be found on the local filesystem at: /var/lib/tomcat6/webapps/ROOT/index.html

Tomcat6 veterans might be pleased to learn that this system instance of Tomcat is installed with CATALINA_HOME in /usr/share/tomcat6 and CATALINA_BASE in /var/lib/tomcat6 So, based in this information, the /usr/share/... folder was kept for backward compatibility, right?

But according to what you posted libs are being read from the CATALINA_HOME instead of CATALINA_BASE.

Perhaps they still keep that default reference to prevent other systems to stop working after updating?

Good observation!

UPDATE:

I read this at: /usr/share/tomcat6/bin/catalina.sh :

Quote:

# CATALINA_HOME May point at your Catalina "build" directory.
#
# CATALINA_BASE (Optional) Base directory for resolving dynamic portions
# of a Catalina installation. If not present, resolves to
# the same directory that CATALINA_HOME points to.

When we read at: /开发者_如何学编程etc/init.d/tomcat6 :

(at the beginning)

CATALINA_HOME=/usr/share/$NAME

(then...)

# Directory for per-instance configuration files and webapps
CATALINA_BASE=/var/lib/$NAME

However, If you try to start TOMCAT manually (as I did long time ago) with: sudo /usr/share/tomcat6/bin/startup.sh

It displays:

Quote:

Using CATALINA_BASE: /usr/share/tomcat6
Using CATALINA_HOME: /usr/share/tomcat6
Using CATALINA_TMPDIR: /usr/share/tomcat6/temp
Using JRE_HOME: /usr
touch: cannot touch `/usr/share/tomcat6/logs/catalina.out': No such file or directory
/usr/share/tomcat6/bin/catalina.sh: 357: cannot create /usr/share/tomcat6/logs/catalina.out: Directory nonexistent

So, why here CATALINA_BASE is set to the same as CATALINA_HOME?

/usr/share/tomcat6/logs/ do not exist, but exists in /var/lib/tomcat6/logs/

I see that my logs are writing into /var/lib/... when starting Tomcat from the init.d script. So its better starting it from there.


I'm not an expert on Tomcat but I was having this same problem and I was able to restart the server with the command: sudo /etc/init.d/tomcat6 restart


CATALINA_HOME -- tells "org.apache.catalina.startup.Bootstrap" where to look for required /lib /bin and other -- which are dependencies to run the server . It is basically your Tomcat installation home directory.

CATALINA_BASE -- expects a certain directory structure to scan for (once started). For example /conf to find server.xml and web.xml which is specific to a web application. as long as you have got that directory structure and content, CATALINA_BASE can be any directory.


I've seen that.

The proper and cute way is to create a "setenv.sh" script into your CATALINA_HOME/bin folder(in your case "/usr/share/tomcat6/bin/setenv.sh").

The contents of your setenv.sh:

#!/bin/sh
export CATALINA_BASE=/new/catalinabase/path

So there is no need to modify catalina.sh by yourself. If setenv.sh is present in bin directory, catalina.sh will execute it automatically.


I can't tell you why CATALINA_HOME and CATALINA_BASE are the same in startup.sh (resp. catalina.sh) - that's really strange.

Of course you can start Tomcat via the init.d script. But sometimes you may want to start it via startup.sh/catalina.sh (e.g. for debugging).

So as a workaround/hack you can correct the problem by adding the following line at the beginning of /usr/share/tomcat6/bin/catalina.sh

export CATALINA_BASE=/var/lib/tomcat6


I could do this by executing this command,

$ service tomcat6 start

which reinitialized my CATALINA_* path and starts the tomcat instance


chmod +x startup.sh
chmod +x shutdown.sh
chmod +x catalina.sh
chmod +x setclasspath.sh
chmod +x bootstrap.jar
chmod +x tomcat-jni.jar

hope it will be work.

0

精彩评论

暂无评论...
验证码 换一张
取 消