#956804 tomcat9: No way to set CATALINA_OPTS as catalina.sh environment variable

Package:
tomcat9
Source:
tomcat9
Submitter:
Radosław Józwik
Date:
2023-02-21 14:03:06 UTC
Severity:
normal
#956804#5
Date:
2020-04-15 12:35:18 UTC
From:
To:
Dear Maintainer,

there is no way to set CATALINA_OPTS environment variable to be used by catalina.sh
startup script. As described in catalina.sh source:

#   CATALINA_OPTS   (Optional) Java runtime options used when the "start",
#                   "run" or "debug" command is executed.

It is working in tomcat8 package from Debian 9 by setting CATALINA_OPTS
in /etc/default/tomcat8.

#956804#10
Date:
2020-11-24 00:02:09 UTC
From:
To:
Le 2020-04-15 14:35, Radosław Józwik a écrit :

Hi Radosław, you should use JAVA_OPTS instead of CATALINA_OPTS in
/etc/default/tomcat9 as documented in the file. I don't think
CATALINA_OPTS has ever been intended to be supported in
/etc/default/tomcat<n>.

Emmanuel Bourg

#956804#15
Date:
2020-11-24 00:02:09 UTC
From:
To:
Le 2020-04-15 14:35, Radosław Józwik a écrit :

Hi Radosław, you should use JAVA_OPTS instead of CATALINA_OPTS in
/etc/default/tomcat9 as documented in the file. I don't think
CATALINA_OPTS has ever been intended to be supported in
/etc/default/tomcat<n>.

Emmanuel Bourg

#956804#20
Date:
2020-11-25 22:07:47 UTC
From:
To:
Hello,

I'm already using JAVA_OPTS as a workaround, but I thought CATALINA_OPTS
should be supported as it is in Tomcat8 package. Nevertheless if
JAVA_OPTS should be used then I will migrate completely and this bug
report can be closed.

Regards,
Radosław

#956804#25
Date:
2023-02-21 13:38:07 UTC
From:
To:
Reading this discussion, I see that at the moment there is not any
official way to declare and expose an environment variable to
"catalina.sh".

I mean, for example, if you need to define this env:
(note, it's not a system property):

MY_CUSTOM_APPLICATION_SECRET=123

In short, this is the current situation of this package AFAIK:

1.
Any extra "Environment=FOO=BAR" variable set from systemd is ignored.
(Also if you force that with PassEnvironment=FOO)
Feature? Probably yes.

2.
Any extra environent variable set from /etc/default/tomcat9 is NOT
exposed to "bin/catalina.sh".
Feature? Probably yes.

[MOST IMPORTANT POINT]
3.
The supposed path to declare an extra env variable should be
"bin/setenv.sh", but, this is in a read-only location as per FHS and so
it's NOT supposed to be customized.
Feature? Probably NO.

If I'm correct:

It would probably make sense to discuss the issue n. 3.

For example, allowing a file such as "setenv.sh" to be created in an
officially writable location would probably make sense.

#956804#30
Date:
2023-02-21 14:01:36 UTC
From:
To:
I just want to mention that, I don't see ANY way at all to expose any
custom environment variable to the Tomcat process itself.

Feature? Unsure.

AFAIK If you push an environment variable inside your catalina.sh, (for
example via the previously mentioned setenv.sh), that variable just die
in catalina.sh and - it seems to me - it is never exposed to the
Tomcat's Bootstrap process.

I'd just be curious if what I'm saying makes sense.