Skip to content
Advertisement

installing tomcat 9 on WSL

After installing tomcat 9 on WSL, it isn’t recognized by system.

Since systemctl command doesn’t work on WSL, I used below command:

sudo service tomcat9 start

returning

tomcat9: unrecognized service

I followed 2 ways to install, but the same problem occurred.

References are:

https://www.digitalocean.com/community/tutorials/install-tomcat-9-ubuntu-1804

https://linuxconfig.org/ubuntu-20-04-tomcat-installation

Is there any clue for this problem?

Here is my environment:

windows 10 version 2004

ubuntu 20.04 (WSL)

openjdk version: “1.8.0_265”

update:

I did same process on gcp vm instance on which ubuntu 20.04 is installed to investigate the problem, and found the process has no problem on ubuntu 20.04, not on WSL.

So I assume that this problem is derived from WSL.

Logging all my process expecting someone to find a solution to install tomcat 9 on WSL-ubuntu.

java install

sudo apt update
sudo apt install openjdk-8-jdk

set JAVA_HOME in /etc/environment

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin"

source /etc/environment

tomcat 9 install

sudo apt install tomcat9 tomcat9-admin

check whether port 8080 is open (positive)

ss -ltn

check whether service command works (positive)

sudo service tomcat9 stop
sudo service tomcat9 start

Advertisement

Answer

It seems the tomcat9 package is broken.

To use tomcat9 on your WSL you may either :

  • download tomcat9 and install it by yourself
  • try to repair the broken install

Here is what I did to repair the install on my computer :

  • Download a zip version of tomcat 9 from https://tomcat.apache.org/download-90.cgi
  • in windows explorer open the folder wsl$Ubuntuusrsharetomcat9
  • In order to repair tomcat I copied all the missing folders from the zip to the wsl installation : conf, webapps and work
  • I also had to create the folder for the logs /usr/share/tomcat9/logs (you can either create it from linux shell or from windows explorer in wsl$Ubuntu)
  • Then I could start tomcat with sudo /usr/share/tomcat9/bin/startup.sh and get the logs in /usr/share/tomcat9/logs/catalina.out
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement