开发者

How to kill Tomcat when running it from Eclipse?

开发者 https://www.devze.com 2023-01-28 20:11 出处:网络
I am running the Tomcat that gets delivered with your Eclipse download (no, I don\'t want to download and install the entire Tomcat), and sometimes i开发者_StackOverflow社区t hangs when stopping or re

I am running the Tomcat that gets delivered with your Eclipse download (no, I don't want to download and install the entire Tomcat), and sometimes i开发者_StackOverflow社区t hangs when stopping or restarting, and the only way I can find to make it work is restarting all my Eclipse. I am using it under Windows.

Is there any way to kill the Tomcat process (which doesn't appear in the Task Manager)?


It appears as javaw.exe in task manager. An alternative is to execute Tomcat/bin/shutdown.bat.

As to the hang problem, are you sure that your webapp isn't spawning unmanaged threads which might be blocking Tomcat's shutdown?


On Windows, if you know the port Tomcat listens to (below, it is 8080), you can find the PID of the Tomcat process and then kill it from cmd:

> netstat -aon | find "8080"
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       2196
  TCP    [::]:8080              [::]:0                 LISTENING       2196
> taskkill /pid 2196 /f
  SUCCESS: The process with PID 2196 has been terminated.


I use better way to shutdown tomcat when it is not found in task manager.

1) Download TCPView(only 285kb) from following link.

http://technet.microsoft.com/en-in/sysinternals/bb897437.aspx

2) Extract folder and start TCPView application.

3) Right click on java.exe and select End Process option.

this would stop your tomcat easily.. This tool is very useful in monitoring port usage.

NOTE: Running TOMCATPATH/bin/shutdown.bat may not shutdown Tomcat when it contains some demon or unmanaged threads. In such cases TCPView works fine without any issues.


You can set a timeout on startup and shutdown for your Tomcat server in Eclipse. If these timeouts are exceeded, Eclipse will pop up a message asking you if you want to kill it, or keep waiting.

To set these, double-click the name of the server in your Servers tab. It'll open a window like this:

How to kill Tomcat when running it from Eclipse?

There's a Timeouts section on the right hand side. I set startup to a day (so I can debug startup without it timing out), and shutdown to 30 seconds to be generous (usually this can be very short, since most apps can survive a forced shutdown with no issues).


If you use Linux, try the following steps.

  1. List Tomcat processes (e.g., ps aux | grep catalina)
  2. Locate the strings that look like this: myname 2244 5.5 0.3 57020937 2110741 ? Sl Oct03 5160:01 /usr/lib/jvm/java-1.8.0-<...>/bin/java <...> org.apache.catalina.startup.Bootstrap start
  3. Copy-paste everything between /usr/lib/jvm/<...> and <...>.Bootstrap
  4. Add stop at the end of your command and run it

Essentially, you would take the very same command that was used by Eclipse to start Tomcat and modify the last argument to stop Tomcat.

0

精彩评论

暂无评论...
验证码 换一张
取 消