vscode-tomcat icon indicating copy to clipboard operation
vscode-tomcat copied to clipboard

Does not seem to work with Tomcat installed via Homebrew on a Mac

Open StasD opened this issue 6 years ago • 8 comments

  • VSCode Version: latest
  • OS Version: mac
  • Tomcat Extension Version: latest

Steps to Reproduce:

  1. Select "Add Tomcat Server"
  2. Go to the root folder ("/"). Press Command-Shift-. (period). Go to folder "/usr/local/Cellar/tomcat/9.0.10".
  3. See the message "Please make sure you select a valid Tomcat Directory."

Update: If I select "libexec" subfolder, it gets added. But it is shown in red, while Tomcat is already running as Homebrew service (brew services start tomcat)...

StasD avatar Jul 21 '18 20:07 StasD

Hi @StasD, the issue does exist, I will check and fix it.

SummerSun avatar Jul 24 '18 04:07 SummerSun

I believe the problem is that vscode-tomcat copies the server file into a temp directory per-workspace. This means that vscode-tomcat will attempt to run/debug on the workspace specific version of tomcat. This, of course, will fail due to the fact that there is already a tomcat server running.

Obviously, @SummerSun knows a lot better. However, If I'm correct, this problem becomes pretty hard to fix without a decent refactor.

In the meantime, I would recommend the following workaround if you're absolutely dying to use this plugin:

  1. Disable the autostart of tomcat by brew. This will enable vscode-tomcat to launch correctly, assuming I'm correct.
  2. Optional: Depending on permissions, download tomcat from https://tomcat.apache.org/download-90.cgi and use that as your tomcat folder.

@JustAnotherSoftwareDeveloper makes a very good point. I want to add another one: you could just change the server points and then there is no necessary to disable the autostart of tomcat by the brew. And our plugin supports that.

The server icon keeps red even if you add the tomcat server successfully is because, the plugin maintains the state within its own scope, it is hard for it to check the server stater outside.

SummerSun avatar Jul 26 '18 00:07 SummerSun

Thanks @SummerSun and @JustAnotherSoftwareDeveloper. Though I have actually figured it out already. If I stop the tomcat server by the brew ("brew services stop tomcat"), and point the vscode-tomcat plugin to the "libexec" subfolder of "/usr/local/Cellar/tomcat/9.0.10", everything works just fine. I can then start / stop the server, and deploy and debug .wars using the plugin. So maybe there is no need to change the code. Just mention homebrew workflow in the documentation. Btw, regardless if I use brew's install of tomcat, or a separate folder, I still have to disable brew's autorun, because it would use same TCP ports, and thus the second install will not work... Maybe this is how you can detect if the machine already has tomcat server running and add it automatically?

StasD avatar Jul 26 '18 01:07 StasD

Also I found out in the last few days that the latest fashion is not to deploy .wars to the tomcat server, but have it as part of the application as a dependency. E.g. Sprint Boot by default creates projects that work like this. But somehow this does not feel quite right to me, just yet... :)

StasD avatar Jul 26 '18 01:07 StasD

@StasD add tomcat server will just check if it is a valid tomcat server directory which requires conf/server.xml, conf/web.xml, bin/bootstrap.jar etc. It will not check the running state of tomcat server. But add server will do a copy conf files and resoures files, that's why it failed if you have the server running.

SummerSun avatar Jul 26 '18 01:07 SummerSun

We are going to release a new version of the extension, and we will mention in the document that the extension just takes care of the server status within the extension for users to avoid this confusion.

SummerSun avatar Nov 08 '18 01:11 SummerSun

Please consider to include that the "libexec-directory" of the installation is "a valid Tomcat Directory". I tried to select different folders for ages 8despite being a seasoned developer ;-).

I would suggest "Selected path is not a valid Tomcat Directory. Please select the libexec directory of your Tomcat installation."

cebulon avatar Jan 15 '20 20:01 cebulon