2

I am trying to set the environment variables GEOSERVER_MODULE_SYSTEM_ENVIRONMENT_STATUS_ENABLED=true and GEOSERVER_MODULE_SYSTEM_PROPERTY_STATUS_ENABLED=true on our development installation of GeoServer so I can see the environment and java system properties from the GeoServer web admin Server Status > Modules tab. I can see them set in my system environment variables when I run printenv on my machine, but GeoServer still does not allow me to view the environment or java system properties from Server Status > Modules tab.

System:

  • RHEL 9
  • Tomcat 9.0.87
  • GeoServer 2.25.3
  • OpenJDK Java 11 / JVM Version: 11.0.24+8-LTS

To set the environment variables, as the root user on the machine, I have made an shell script and added it to /etc/profile.d. The script is called geoserver.sh and it looks like this:

export GEOSERVER_MODULE_SYSTEM_ENVIRONMENT_STATUS_ENABLED=true
export GEOSERVER_MODULE_SYSTEM_PROPERTY_STATUS_ENABLED=true

I then logged out and logged back in, ran printenv and saw the two environment variables appear as I expected. I restarted tomcat and then logged into our web admin interface and still I get the same message when trying to view the System Environment module popup and the System Properties module popup:

Environment variables hidden for security reasons.  Set the environment variable 'GEOSERVER_MODULE_SYSTEM_ENVIRONMENT_STATUS_ENABLED' to 'true' to see them.
Java system properties hidden for security reasons.  Set the environment variable 'GEOSERVER_MODULE_SYSTEM_PROPERTY_STATUS_ENABLED' to 'true' to see them.

Am I adding the environment variables in the wrong place? I'm not sure what to do here. I have tried adding them as JAVA_OPTS and CATALINA_OPTS in Tomcat and it didn't work either (not that I expected it to).

I did log in as a different user other than root and ran printenv and can still see the GEOSERVER env variables set, so it stands to reason that the tomcat user (a non-login user) that runs GeoServer should also be able to see them. I don't get why GeoServer doesn't.

If I run the command that the documentation I linked to earlier says to get a list of environment variables (tr '\0' '\n' < /proc/${GEOSERVER_PID}/environ), I get this list which suggests environment variables aren't being set at GeoServer startup... but I don't get where I would set them then.

SECURITY_MANAGER=false
JAVA_HOME=/usr/lib/jvm/jre
TOMCAT_CFG_LOADED=1
JAVA_OPTS=-Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory
NAME=
PWD=/usr/share/tomcat
LOGNAME=tomcat
SYSTEMD_EXEC_PID=2799947
HOME=/usr/share/tomcat
LANG=en_US.UTF-8
TOMCATS_BASE=/var/lib/tomcats/
INVOCATION_ID=f184a53cc970459eb7757bf289220a38
CATALINA_HOME=/usr/share/tomcat
USER=tomcat
SHLVL=0
JDK_JAVA_OPTIONS= --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-
CATALINA_TMPDIR=/var/cache/tomcat/temp
JOURNAL_STREAM=8:57568628
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
OLDPWD=/

My Tomcat installation does not include files like catalina.sh or startup.sh or setenv.sh because it's RHEL 9 which uses system.d for configuration. Instead things like CATALINA_OPTS or JAVA_OPTS are set in /etc/tomcat/tomcat.conf or a custom file in /etc/tomcat/conf.d/yourcustomstuff.conf. I already tried that. And those aren't "environment variables" anyway, those are java system properties which is not what the documentation is stating GEOSERVER_MODULE_SYSTEM_ENVIRONMENT_STATUS_ENABLED and GEOSERVER_MODULE_SYSTEM_PROPERTY_STATUS_ENABLED are.

1 Answer 1

2

To future readers, here's what worked for me, but I am running a RHEL 9 that uses systemd type of configuration (.conf files everywhere, basically) so this process is likely not the same for other Linux OS. It seems Tomcat installations on other Linux OS have different files than a RHEL 9 Tomcat installation. Your mileage may vary.

I was interpreting the documentation as stating those two variables should be system-wide environment variables, but it dawned on me that since the documentation says to check environment variables for GeoServer using this command: tr '\0' '\n' < /proc/${GEOSERVER_PID}/environ that the documentation is not actually referring to system-wide environment variables. They are also not referring to java system properties either though, so JAVA_OPTS and/or CATALINA_OPTS are not relevant here. The key is understanding that when the documentation says "get a list of all environment variables set at GeoServer startup" that it is referring to the tomcat environment because that is what starts GeoServer. So, with that in mind, I edited my /etc/tomcat/tomcat.conf file and added two variables, NOT as part of JAVA_OPTS, but as individual variables:

GEOSERVER_MODULE_SYSTEM_ENVIRONMENT_STATUS_ENABLED=true
GEOSERVER_MODULE_SYSTEM_PROPERTY_STATUS_ENABLED=true

When I restarted tomcat (systemctl restart tomcat) and logged out of the web interface and back in again, I was finally able to see the GeoServer environment and java system property variables list in their respective popups.

This is my full tomcat.conf file:

# This variable is used to figure out if config is loaded or not.
TOMCAT_CFG_LOADED="1"

# In new-style instances, if CATALINA_BASE isn't specified, it will
# be constructed by joining TOMCATS_BASE and NAME.
TOMCATS_BASE="/var/lib/tomcats/"

# Where your java installation lives
JAVA_HOME="/usr/lib/jvm/jre"

# Where your tomcat installation lives
CATALINA_HOME="/usr/share/tomcat"

# System-wide tmp
CATALINA_TMPDIR="/var/cache/tomcat/temp"

# You can pass some parameters to java here if you wish to
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"

# Use JAVA_OPTS to set java.library.path for libtcnative.so
#JAVA_OPTS="-Djava.library.path=/usr/lib"

# Set default javax.sql.DataSource factory to apache commons one. See rhbz#1214381
JAVA_OPTS="-Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory"

# You can change your tomcat locale here
#LANG="en_US"

# Run tomcat under the Java Security Manager
SECURITY_MANAGER="false"

# SHUTDOWN_WAIT has been deprecated. To change the shutdown wait time, set
# TimeoutStopSec in tomcat.service.

# If you wish to further customize your tomcat environment,
# put your own definitions here
GEOSERVER_MODULE_SYSTEM_ENVIRONMENT_STATUS_ENABLED=true
GEOSERVER_MODULE_SYSTEM_PROPERTY_STATUS_ENABLED=true

Extra Notes: To run the first command in this answer, you can get your GEOSERVER_PID by running the command ps -ef | grep tomcat and it will return a list of process IDs of applications/services tomcat is running. One of them will be the GEOSERVER_PID; I can tell which one on mine is geoserver because I have added some java system properties specific to geoserver which show up in the output.

tomcat   2817895       1 10 17:25 ?        00:01:00 /usr/lib/jvm/jre/bin/java -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -DGEOSERVER_CSRF_WHITELIST=hy/
root     2819934 2816977  0 17:35 pts/1    00:00:00 grep --color=auto tomcat

In this example, the GEOSERVER_PID is 2817895

4
  • the most likely issue is that the tomcat user doesn't run a login shell so it doesn't run profile
    – Ian Turton
    Commented Aug 11 at 10:37
  • Got it, that does make sense. Having never configured tomcat before and being a total newbie with Linux, I still have plenty to wrap my head around!
    – MKF
    Commented Aug 11 at 16:42
  • Did you know that you can edit the GeoServer documentation to help others find this information
    – Ian Turton
    Commented Aug 11 at 18:10
  • No, I didn't know that. I just found the link to the guide on editing the docs, I'll give it a look.
    – MKF
    Commented Aug 11 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.