4

I have a Ubuntu Server 10.10 64-bit running a web application on Jetty 6.1.24-6 on Sun's JVM, both installed from standard Ubuntu repositories.

I'm trying to track down a problem with this server (100% cpu after some time, it might be related to a known bug on NIO's Selector, although it looks like changing the connector to old io SocketConnector didn't solve the problem!), and need to take a thread dump.

Unfortunately I'm unable to get the thread dump. I've tried to send a SIGQUIT to the process, and tried to attach JStack to it, but neither approach works.

I see no output at all from SIGQUIT (in any of the log files generated by Jetty), and JStack, even when run as root (or jetty) and with "-F", says that it has been attached to the process, but then blocks and produces no more output!

How can I obtain the thread dump?

Bruno Reis
  • 37,201
  • 11
  • 119
  • 156
  • See my question here, I have taken some Thread dumps that might help you: http://stackoverflow.com/questions/7404844/jetty-service-thread-crashes-and-uses-100-cpu – gub Sep 13 '11 at 16:01

2 Answers2

6

You have to do this as the same user as the jetty process is running under. On Ubuntu this user is normally called jetty.

So try

sudo -u jetty jstack <pid>

this will send a thread dump to stdout (your shell).

You can also

sudo -u jetty kill -QUIT <pid>

which will send the thread dump to jetty's stdout (normally /var/log/jetty/out.log)

To get the pids use the jps command or ps ax|grep java

Dr.Haribo
  • 1,778
  • 1
  • 31
  • 43
  • ```ps ax | grep java``` usually outputs several processes, which one should I use? – Q i Jan 26 '17 at 18:22
0

did you try VisualVM (/usr/lib/java-6-sun/bin/jvisualvm) with remote connection ? It can capture a thread dump

Grooveek
  • 10,046
  • 1
  • 27
  • 37
  • I don't know why, but it does not work. I've added some -D parameters to the JVM, the port 1099 is open at the server. I add a connection on VisualVM, it says "connecting..." but never go further. More strange is that the connection is indeed established, as shown by a 'netstat' both on the client (my machine) and on the server! – Bruno Reis May 19 '11 at 18:21
  • how did you establish the connection ? via JMX or a jstatd daemon ? – Grooveek May 19 '11 at 19:46
  • 1099 seems to be a port of a rmi registry... what url did you configure in your JMX connection ? – Grooveek May 19 '11 at 19:48
  • With visualvm it only asks for a host and port. I'm not sure if 1099 is the correct port. Look at the accepted answer to this question: http://stackoverflow.com/questions/1755819/cpu-and-profiling-not-supported-for-remote-jvisualvm-session – Sarel Botha Sep 13 '11 at 16:10