I also faced such situation Directory is invalid /opt/apache-tomcat-9/conf/Catalina
. So what I did is basically I remove all tomcat apt packages
sudo apt remove --purge tomcat9 tomcat9-docs
sudo apt autoremove
sudo apt autoclean
After that I download tomcat9 binary link and extract it and create a soft link for easy use
sudo tar -xvf ~/Downloads/<binary-name> -C /usr/local
cd /usr/local
sudo ln -s <tomcat-9-directory-name> tomcat9
change the mod of the tomcat9
directory
sudo chmod -R 777 tomcat9/
Then goto intelliJ and navigateFile > Settings > Build, Execution, Deployment > Application Servers
. Remove tomcat settings if available(minus icon). Then add new Tomcat server by pressing plus icon. Set Tomcat home path as/usr/local/tomcat9
and press ok.

Once you finished it, open the configuration dialog Run > Edit Configurations
and remove Tomcat servers if there any. And Press plus icon and select Tomcat Server. Then goto the Deployment tab and press plus sign and add the artifact that you want to deploy. Then press ok and re-run the application.