Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we generate stack trace in TOMCAT?

Tags:

tomcat

How do we generate stack trace in TOMCAT? My real problem is TOMCAT just stops after doing some function call defined in some library. It would be easy to debug with a stacktrace.

like image 360
user518796 Avatar asked Dec 01 '25 15:12

user518796


1 Answers

There's multiple things you can do. I'm assuming below you are talking about a Java stack trace.

In linux, you can generate a stack trace at any time by doing a kill -3 command

ps aux | grep tomcat --> gives you the process number

kill -3 1000 --> where 1000 is the process number

In Windows, right click on the Tomcat service icon in the system task tray and choose "Thread dump".

If you want to generate a stack trace at a particular point in the code

Throwable t = new RuntimeException();
t.printStackTrace();

All of the above will send a stack trace to standard out.

Finally, you can run a profiling program like VisualVM and see the stack trace for any given thread while the program is running.

like image 178
Will Glass Avatar answered Dec 04 '25 00:12

Will Glass



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!