Bug 1523248 - tomcat systemd does not cope with - in service names.
Summary: tomcat systemd does not cope with - in service names.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: tomcat
Version: 31
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Coty Sutherland
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1523112
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-07 14:02 UTC by Coty Sutherland
Modified: 2019-10-04 21:56 UTC (History)
9 users (show)

Fixed In Version: tomcat-9.0.26-1.fc31 tomcat-9.0.26-2.fc30 tomcat-9.0.26-2.fc29
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1523112
Environment:
Last Closed: 2019-10-04 20:05:09 UTC


Attachments (Terms of Use)

Description Coty Sutherland 2017-12-07 14:02:42 UTC
+++ This bug was initially created as a clone of Bug #1523112 +++

Description of problem:

Installing a service called ntis-adapter the - causes issues with systemd/tomcat start/stop where by it does not load the specific configuration in /etc/sysconfig/tomcat@ntis-adapter



Version-Release number of selected component (if applicable):

systemd-219-42.el7_4.4.x86_64
tomcat-7.0.76-3.el7_4.noarch

How reproducible:


Steps to Reproduce:
1. Create tomcat service with a - in the name using this RHEL soloution (https://access.redhat.com/solutions/2386441)

2. Attempt to start the service - Errors will occour as it will look in /var/lib/tomcats instead of looking at the correct CATALINA_BASE

3. Rename the service removing the - and rename the configuration in /etc/sysconfig

4. Start the service - It works and loads in the configuration values correctly

Actual results:

Dec 07 09:13:06 NECA-web-client server[20100]: Dec 07, 2017 9:13:06 AM org.apache.catalina.startup.Catalina load
Dec 07 09:13:06 NECA-web-client server[20100]: WARNING: Unable to load server configuration from [/var/lib/tomcats/ntis/adapter/conf/server.xml]
Dec 07 09:13:06 NECA-web-client server[20100]: Dec 07, 2017 9:13:06 AM org.apache.catalina.startup.Catalina load
Dec 07 09:13:06 NECA-web-client server[20100]: WARNING: Unable to load server configuration from [/var/lib/tomcats/ntis/adapter/conf/server.xml]
Dec 07 09:13:06 NECA-web-client server[20100]: Dec 07, 2017 9:13:06 AM org.apache.catalina.startup.Catalina start
Dec 07 09:13:06 NECA-web-client server[20100]: SEVERE: Cannot start server. Server instance is not configured.
Dec 07 09:13:06 NECA-web-client server[20131]: Java virtual machine used: /usr/lib/jvm/jre/bin/java
Dec 07 09:13:06 NECA-web-client server[20131]: classpath used: /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar
Dec 07 09:13:06 NECA-web-client server[20131]: main class used: org.apache.catalina.startup.Bootstrap
Dec 07 09:13:06 NECA-web-client server[20131]: flags used:
Dec 07 09:13:06 NECA-web-client server[20131]: options used: -Dcatalina.base=/var/lib/tomcats/ntis/adapter -Dcatalina.home=/usr/share/tomcat -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat/temp -Djava.util.logging.config.file=/usr/share/tomcat/conf/logging.prope
Dec 07 09:13:06 NECA-web-client server[20131]: arguments used: stop
Dec 07 09:13:07 NECA-web-client server[20131]: java.util.logging.ErrorManager: 4: Unable to create [/var/lib/tomcats/ntis/adapter/logs]
Dec 07 09:13:07 NECA-web-client server[20131]: java.util.logging.ErrorManager: 4: Unable to create [/var/lib/tomcats/ntis/adapter/logs]
Dec 07 09:13:07 NECA-web-client server[20131]: java.util.logging.ErrorManager: 4: Unable to create [/var/lib/tomcats/ntis/adapter/logs]
Dec 07 09:13:07 NECA-web-client server[20131]: java.util.logging.ErrorManager: 4: Unable to create [/var/lib/tomcats/ntis/adapter/logs]
Dec 07 09:13:07 NECA-web-client server[20131]: Dec 07, 2017 9:13:07 AM org.apache.catalina.startup.Catalina stopServer
Dec 07 09:13:07 NECA-web-client server[20131]: SEVERE: Catalina.stop:
Dec 07 09:13:07 NECA-web-client server[20131]: java.io.FileNotFoundException: /var/lib/tomcats/ntis/adapter/conf/server.xml (No such file or directory)
Dec 07 09:13:07 NECA-web-client server[20131]: at java.io.FileInputStream.open0(Native Method)
Dec 07 09:13:07 NECA-web-client server[20131]: at java.io.FileInputStream.open(FileInputStream.java:195)
Dec 07 09:13:07 NECA-web-client server[20131]: at java.io.FileInputStream.<init>(FileInputStream.java:138)
Dec 07 09:13:07 NECA-web-client server[20131]: at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:466)
Dec 07 09:13:07 NECA-web-client server[20131]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Dec 07 09:13:07 NECA-web-client server[20131]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Dec 07 09:13:07 NECA-web-client server[20131]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Dec 07 09:13:07 NECA-web-client server[20131]: at java.lang.reflect.Method.invoke(Method.java:498)
Dec 07 09:13:07 NECA-web-client server[20131]: at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:343)
Dec 07 09:13:07 NECA-web-client server[20131]: at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:430)
Dec 07 09:13:07 NECA-web-client systemd[1]: tomcat@ntis-adapter.service: control process exited, code=exited status=1
Dec 07 09:13:07 NECA-web-client systemd[1]: Unit tomcat@ntis-adapter.service entered failed state.
Dec 07 09:13:07 NECA-web-client systemd[1]: tomcat@ntis-adapter.service failed.


Expected results:
 (Configuration error in above setup - Complains about missing vairable (Reads the configuration file this time)

Dec 07 09:16:24 NECA-web-client polkitd[833]: Unregistered Authentication Agent for unix-process:20229:23509515 (system bus name :1.1357, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_GB.UTF-8) (disconnected from bus)
Dec 07 09:16:24 NECA-web-client server[20235]: Java virtual machine used: /usr/lib/jvm/jre-1.8.0/bin/java
Dec 07 09:16:24 NECA-web-client server[20235]: classpath used: /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar
Dec 07 09:16:24 NECA-web-client server[20235]: main class used: org.apache.catalina.startup.Bootstrap
Dec 07 09:16:24 NECA-web-client server[20235]: flags used: ${JAVA_OPTS} -Dspring.profiles.active=live,default -Duser.timezone=Europe/London -Dlog4j.configuration=file:${CATALINA_BASE}/conf/ntis-adapter/log4j.xml -server -Xms1024m -Xmx4096m -XX:MaxPermSize=1024m
Dec 07 09:16:24 NECA-web-client server[20235]: options used: -Dcatalina.base=/opt/mottMacDonald/adapters/ntis-adapter/active -Dcatalina.home=/usr/share/tomcat -Djava.endorsed.dirs= -Djava.io.tmpdir=${CATALINA_BASE}/temp -Djava.util.logging.config.file=/usr/share/tomcat/c
Dec 07 09:16:24 NECA-web-client server[20235]: arguments used: start
Dec 07 09:16:24 NECA-web-client server[20235]: Error: Could not find or load main class ${JAVA_OPTS}


Additional info:


/etc/sysconfig/tomcat@ntis-service

# Service-specific configuration file for tomcat. This will be sourced by
# the SysV init script after the global configuration file
# /etc/tomcat/tomcat.conf, thus allowing values to be overridden in
# a per-service manner.
#
# NEVER change the init script itself. To change values for all services make
# your changes in /etc/tomcat/tomcat.conf
#
# To change values for a specific service make your edits here.
# To create a new service create a link from /etc/init.d/<your new service> to
# /etc/init.d/tomcat (do not copy the init script) and make a copy of the
# /etc/sysconfig/tomcat file to /etc/sysconfig/<your new service> and change
# the property values so the two services won't conflict. Register the new
# service in the system as usual (see chkconfig and similars).
#

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

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

# Where your tomcat installation lives
CATALINA_BASE="/opt/mottMacDonald/adapters/ntis-adapter/active"
CATALINA_TMPDIR="${CATALINA_BASE}/temp"
CATALINA_OPTS="-server -Xms1024m -Xmx4096m -XX:MaxPermSize=1024m"

#
#Java configuration options
#
JAVA_OPTS="${JAVA_OPTS} -Dspring.profiles.active=live,default -Duser.timezone=Europe/London -Dlog4j.configuration=file:${CATALINA_BASE}/conf/ntis-adapter/log4j.xml"

#
# Pid Location
#
CATALINA_PID="/var/run/ntis-adapter.pid"

#
# User Information
#
TOMCAT_USER="osprey"

#
# Security Manager defaulted to off
#
SECURITY_MANAGER="false"

--- Additional comment from Lukáš Nykrýn on 2017-12-07 04:34:11 EST ---

If I am not mistaken, we don't support variable expansion in environment files, so this:
JAVA_OPTS="${JAVA_OPTS} -Dspring.profiles.active=live,default -Duser.timezone=Europe/London -Dlog4j.configuration=file:${CATALINA_BASE}/conf/ntis-adapter/log4j.xml"
and
CATALINA_TMPDIR="${CATALINA_BASE}/temp"
can't work.

--- Additional comment from Joe Madden on 2017-12-07 04:36:08 EST ---

Yep - your correct. I've just fixed this in my config.

Please note this is not about my service not working, currently in the process of fixing it but it wouldn't load any of the virables while i had a dash in the service name.

Removed that and it is now loading CATALINA_BASE


Thanks

--- Additional comment from Lukáš Nykrýn on 2017-12-07 06:28:47 EST ---

Hmm, looks like there is a bug.

Minimal reproducer:
[root@qeos-13 system]# cat /etc/systemd/system/test@.service
[Service]
EnvironmentFile=/etc/sysconfig/test%I
Type=oneshot
ExecStart=/usr/bin/env
[root@qeos-13 system]# touch /etc/sysconfig/testa-a
[root@qeos-13 system]# systemctl start test@a-a.service
Job for test@a-a.service failed because a configured resource limit was exceeded. See "systemctl status test@a-a.service" and "journalctl -xe" for details.

The same problem seems to be also in upstream version of systemd (systemd-235-4.fc28.x86_64)

--- Additional comment from Lukáš Nykrýn on 2017-12-07 08:33:41 EST ---

Ok, so the problem is not in systemd, it behaves correctly, although the error message is terrible and I had to look into the code to see what is actually wrong. But anyway. https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Specifiers
"%i" - For instantiated units: this is the string between the "@" character and the suffix of the unit name.
"%I" - Same as "%i", but with escaping undone.

THis means that systemd will do unescaping which in this case means that instead of /etc/sysconfig/tomcat@ntis-adapter systemd is looking at /etc/sysconfig/tomcat@ntis/adapter

So in short: Tomcat needs to replace %I with %i in their unit file.

Comment 1 Fedora End Of Life 2018-02-20 15:31:40 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 28 development cycle.
Changing version to '28'.

Comment 2 Ben Cotton 2019-05-02 22:04:25 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 3 Ben Cotton 2019-08-13 16:50:46 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to '31'.

Comment 4 Ben Cotton 2019-08-13 19:22:01 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to 31.

Comment 6 Fedora Update System 2019-09-26 19:18:40 UTC
FEDORA-2019-846a113a7a has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-846a113a7a

Comment 7 Fedora Update System 2019-09-26 19:18:47 UTC
FEDORA-2019-e5fc063359 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-e5fc063359

Comment 8 Fedora Update System 2019-09-27 02:19:02 UTC
tomcat-9.0.26-2.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-e5fc063359

Comment 9 Fedora Update System 2019-09-27 02:29:15 UTC
tomcat-9.0.26-1.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-ca3a149f36

Comment 10 Fedora Update System 2019-09-27 03:13:40 UTC
tomcat-9.0.26-2.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-846a113a7a

Comment 11 Fedora Update System 2019-10-04 20:05:09 UTC
tomcat-9.0.26-1.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.

Comment 12 Fedora Update System 2019-10-04 21:24:17 UTC
tomcat-9.0.26-2.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.

Comment 13 Fedora Update System 2019-10-04 21:56:50 UTC
tomcat-9.0.26-2.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.