How do i ensure tomcat9 service starts upon system reboot?
Each time it reboots i need to manually go and type
systemtl start tomcat9.service.
oot@wiki:~# systemctl enable tomcat9
Failed to lookup unit file state: Invalid argument
Any ideas please?
Hi, I don’t know and I think you’d have better chance asking on the tomcat forum
Actually seems to be generic linux question. I’m sure google will yield lots of results though.
Default install of Xwiki comes with tomcat9,the service doesn’t start on system reboot.
I would assume this should come up on its own. Is this all normal ?
How do we enable tomcat9 to come up by itself on system reboot?
Here is the fix, unsure if this is something the xwiki install should take care of on its own as it brings up the mysql service.
Create a systemd unit file
To make Tomcat run as a service open your text editor and create a tomcat.service
unit file in the /etc/systemd/system/
directory:
sudo nano /etc/systemd/system/tomcat.service
Paste the following content:
/etc/systemd/system/tomcat.service
[Unit]
Description=Tomcat 9 servlet container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/jre"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"
Environment="CATALINA_BASE=/opt/tomcat/latest"
Environment="CATALINA_HOME=/opt/tomcat/latest"
Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/latest/bin/startup.sh
ExecStop=/opt/tomcat/latest/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
Copy
Save and close the file.
Notify systemd that we created a new unit file by typing:
sudo systemctl daemon-reload
Enable and start the Tomcat service:
So you didn’t mention but I’ll assume you’ve used the xwiki debian packaging (we have plenty of different packagings). This packaging has tomcat as a dependency but we don’t “own” tomcat. You could have an existing tomcat instance already or you may want to use it run other webapps. Whether your tomcat instance starts automatically at boot or not is up to you, XWiki cannot control that.
Glad you found the solution and thanks for posting it!