Debugging Apache Tomcat shutdown issues

I have Tomcat installed as a windows service and sometimes it freezes when I try to shut it down (via services.msc). I tried to connect to it using a debugger, but I don't seem to understand why it hangs.

When I try to look at one of the threads by executing "Thread.getThreads () [0]", I get an error from the debugger: "Stack frame unavailable".

If, instead of closing the whole Tomcat, I just dump all my servlet contexts, everything works fine.

How can you debug this? Is this by definition a bug in Tomcat?

+2


source to share


3 answers


I dont think it is a bug in tomcat as my cats are closed normally.

If you say that everything is fine when offloading all web applications, the problem might be with one of the web applications. Try to unload only one at a time. turn off the cat and see what happens. if it's a web app that is causing the problem, after unloading it, you won't have a problem.

Another question: what happens when you do it from the command line (and not from the services screen)?

Edit

To debug remotely you need to add the following to JAVA_OPTS



JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

      

Then you can hook into an IDE process like eclipse (look for remote debugging). You can download the source from here . What you are looking for (I think) are methods that implement Lifecycle.stop () or implement LifecycleListener . Sorry, I cannot be more specific.

Edit 2

One more thing - if this is your development machine, I found it better to run eclipse not as a service but from the command line or directly from the IDE

+1


source


For completeness, I have to ask: have you checked Tomcat's own log files?

%TomcatHome%\logs

      

which is probably something like ...



C:\Program Files\Apache Software Foundation\Tomcat 6.0\logs

      

Please forgive me if this is the first thing you tried, but you didn't mention it, so I figured I'd just ask to be sure.

+1


source


One thing you can try to do is use a profiler to see what objects are left in memory after shutdown.

I ran into a similar problem where my codebase had a "logical memory leak". The vocabulary must be carefully chosen because java garbage collection prevents most memory leaks. Logical memory leaks are created by programmers who are not as careful as they should be, or are under too much time.

Anyway, we used JProfile to see which objects were still alive in the VM, and we found out that some threads were not properly accounted for during shutdown. If you can find out which objects are still alive, you will have a hint as to why tomcat is not closing completely.

0


source







All Articles