Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a complete stack trace of a running java program that is taking 100% cpu?

I do have a jenkins instance that is stuck in some kind of endless loop without any visible activity.

I can get the pid of the running process so how do I generate a trace that I can use for a bug report?

I'm running on linux.

like image 535
sorin Avatar asked May 25 '12 14:05

sorin


People also ask

How can I get the current stack trace in Java?

You can use Thread. currentThread(). getStackTrace() . That returns an array of StackTraceElement s that represent the current stack trace of a program.

How do I print a full stack trace?

Using printStackTrace() method − It print the name of the exception, description and complete stack trace including the line where exception occurred. Using toString() method − It prints the name and description of the exception. Using getMessage() method − Mostly used. It prints the description of the exception.

What is stack traces in Java?

Simply put, a stack trace is a representation of a call stack at a certain point in time, with each element representing a method invocation. The stack trace contains all invocations from the start of a thread until the point it's generated. This is usually a position at which an exception takes place.


1 Answers

Try with jstack. It'll give you a full list of what your threads are doing. All it needs is the process pid.

like image 145
mprivat Avatar answered Oct 18 '22 18:10

mprivat