Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debug java application while startup

It might sound a bit too naive, but I always had a tough time to debug a java class during server startup. Here is the scenario:

  • The java application is hosted on a tomcat server.
  • Suppose there is a class which is invoked while the tomcat server starts up.
  • As soon as I stop the tomcat instance for a restart, the eclipse debug stops and I can start the debug only once the application is up and running.
  • Now how do I debug this class on eclipse?

Thanks for you help in advance.

like image 215
rajugaadu Avatar asked Sep 24 '12 11:09

rajugaadu


1 Answers

You need to pass the "wait for debugger to connect" flag to tomcat. So the startup will wait until you have connected and thus you won't miss the breakpoint.

Take for example those java options to make tomcat listen for a debugger:

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8797,server=y,suspend=y

The wait for a debugger connection flag is the suspend=y entry in the above line.

like image 197
Heiko Rupp Avatar answered Sep 27 '22 23:09

Heiko Rupp