2

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
cornandme
  • 47
  • 2
  • 7
  • Try starting Tomcat from command line, it may indicate the problem. Ensure catalina.sh is on path (manually to tomcat/bin), set JAVA_HOME (set it manually) to the jdk installation root. Check java -version to ensure path setting for JDK to jdk/din directory. Start Tomcat cataline.sh run. This may indicate what the issue is, give it a shot. – Ironluca Aug 08 '20 at 09:09
  • I think you should go to the tomcat install directory to start it. – Holinc Aug 08 '20 at 10:09

2 Answers2

4

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$\Ubuntu\usr\share\tomcat9
  • 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
QuickFix
  • 11,661
  • 2
  • 38
  • 50
  • Wow thanks! worked exactly as specified. One thing to note to others who may stumble upon here, guides usually say to open up 127.0.0.1:8080 to see tomcat running. For me, this didnt work but it was served instead on localhost:8080 which led me to find out that there indeed is a difference :") – Vimuth Jul 27 '21 at 16:30
0

I solved the problem by following steps:

  1. enable systemd, see WSL 2 - Enabling systemd
  2. restart WSL Ubuntu, with cmd wsl --shutdown and wsl -d Ubuntu genie -s
  3. reinstall tomcat9, with shell apt-get remove tomcat9 and apt-get install tomcat9

then type service tomcat9 status, see how things work in your machine.

fuweichin
  • 1,398
  • 13
  • 14