• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Why tomcat8 don't CATALINA_HOME?  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just installed tomcat8 by yum install tomcat8 on AWS EC2, but I can't find any environment variable CATALINA_*, why? is this a normal way?
All installation guide told me that CATALINA_HOME will be set, I don't know why!! Though tomcat can be run and I can view tomcat cover page and only that page, for any click I got error 404...
 
Bartender
Posts: 20727
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Mike!

Based on what you posted, I'm figuring that your AWS VM is running one of the Red Hat OS's, since you're using YUM as the installer.

The processes may be different if you are running RHEL 7/CentoOS 7, since those releases are controlled by systemd, but in the previous versions, the tomcat RPM would install the Tomcat server, an init script in /etc/init.d and a configuration file in /etc/tomcat.

On a RHEL Linux system, neither JAVA_HOME nor CATALINA_HOME are system-wide environment variables, so they are set in the init script, and while the initscript has default values, it will check for overrides in /etc/tomcat, or possibly /etc/sysconfig.

CATALINA_HOME and CATALINA_BASE are 2 filesystem paths that indicate where Tomcat is installed. For simple configurations, CATALINA_BASE is set to the same value as CATALINA_HOME, so we won't worry about it further.

Normally, Tomcat is downloaded as an archive file and unzipped to an installation directory, such as /usr/local or /opt/tomcat, so CATALINA_HOME points to the Tomcat directory. The RPM, however, attempts to make the Tomcat configuration more conformant with standard LSB file conventions, so it introduces a set of softlinks that make CATALINA_HOME/logs appear to be /var/log/tomcat, CATALINA_HOME/conf to be /etc/tomcat, work and webapp directories to appear under /var/lib and /tmp, and so forth. In addition to making things more Linux-like, this also allows working around the LCB requirement that /usr/local should be read-only, in case Tomcat is installed there.

If you're getting a "404" error, then most likely you didn't install your webapps in the right place.
 
Mike Zang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for you reply and detail explanation.
So back to my topic, do I have to export CATALINA_HOME and all other env by manual?
 
Tim Holloway
Bartender
Posts: 20727
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only if you start Tomcat manually (via the catalina.sh script). When starting Tomcat as a system service, the CATALINA_HOME variable is set, as I said, by the init script that controls Tomcat.
 
Mike Zang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is little strange! I run it by command as below:
sudo service tomcat8 start

does this set env auto?
 
Tim Holloway
Bartender
Posts: 20727
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "service" command (/sbin/service) controls services by executing their init scripts.

So yes. The init script (/etc/init.d/tomcat8) sets CATALINA_HOME.
 
Mike Zang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is why I ask this question here because there is no CATALINA_HOME, I put the snapshot, may I make sense? can you tel me why?
noCATALINA_HOME.jpg
[Thumbnail for noCATALINA_HOME.jpg]
 
Tim Holloway
Bartender
Posts: 20727
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every process has its own environment. The environment is not a global space. Although spawning a new process offers the option to clone the parent process environment, changes to the child process' environment won't be reflected in its parent or in any other process environment (such as your command shell session).

In fact, this can cause difficulties when you want to execute a script that will invoke a child script that sets up environment variables, which is why Linux/Unix has the "export" command specifically to push selected child environment variables up to the caller.

So everything is operating as it should be for you.
 
Mike Zang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:Every process has its own environment. The environment is not a global space. Although spawning a new process offers the option to clone the parent process environment, changes to the child process' environment won't be reflected in its parent or in any other process environment (such as your command shell session).

In fact, this can cause difficulties when you want to execute a script that will invoke a child script that sets up environment variables, which is why Linux/Unix has the "export" command specifically to push selected child environment variables up to the caller.

So everything is operating as it should be for you.


Well, so I have do it by myself if I want to those environment variables become global, may I make sense?
Though I thought service starter should do it for me....
 
Tim Holloway
Bartender
Posts: 20727
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want such values to be global? That would interfere with being able to run more than one Tomcat. Having JAVA_HOME be the same in all processes would be even worse, since you could very well have different Java apps running under different versions of Java.

It is sufficient that Tomcat's own process have its CATALINA_HOME properly set. Which was automatically done for you when you started the Tomcat service.
 
Mike Zang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:Why do you want such values to be global? That would interfere with being able to run more than one Tomcat. Having JAVA_HOME be the same in all processes would be even worse, since you could very well have different Java apps running under different versions of Java.

It is sufficient that Tomcat's own process have its CATALINA_HOME properly set. Which was automatically done for you when you started the Tomcat service.


Thanks for your explanation! I know what I should do next time.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!