How to kill Tomcat when running it from Eclipse?

后端 未结 5 2034
粉色の甜心
粉色の甜心 2021-01-31 03:25

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 it hangs when stopping or res

相关标签:
5条回答
  • 2021-01-31 03:35

    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.
    
    0 讨论(0)
  • 2021-01-31 03:40

    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?

    0 讨论(0)
  • 2021-01-31 03:45

    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 讨论(0)
  • 2021-01-31 03:49

    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:

    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).

    0 讨论(0)
  • 2021-01-31 03:59

    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.

    0 讨论(0)
提交回复
热议问题