Shutting down Tomcat with errors (The web application [xwiki] created a ThreadLocal ...)

Thanks Vincent for your fast reply!

I think I’m wrong that those errors message keep my Tomcat from starting automatically after reboot.

But my Tomcat doesn’t start after booting and I’d like to fix it.

My Tomcat service runs fine. I can start and stop it manually without a problem.

I tried to enable the service with sudo systemctl enable tomcat9 but it says

Failed to lookup unit file state: Invalid argument

I guess I found the problem. It’s the link of the systemd drop-in

$ ls -al /etc/systemd/system/tomcat9.service.d
total 8
drwxr-xr-x 2 root root 4096 May 29 23:19 .
drwxr-xr-x 19 root root 4096 May 24 14:18 ..
lrwxrwxrwx 1 root root 37 May 26 14:50 xwiki-tomcat9-systemd.conf -> /etc/xwiki/xwiki-tomcat9-systemd.conf

The link is not allowed as it points to /etc. I found a hint about this rule here: install: follow unit file symlinks in /usr, but not /etc when looking for [Install] data and more by poettering · Pull Request #1515 · systemd/systemd · GitHub

After removing the symlink and copying the former linked file to the same location everything works fine:

$ ls -al /etc/systemd/system/tomcat9.service.d
total 12
drwxr-xr-x  2 root root 4096 May 30 21:40 .
drwxr-xr-x 19 root root 4096 May 24 14:18 ..
-rw-r--r--  1 root root  116 May 30 21:40 xwiki-tomcat9-systemd.conf