简体   繁体   中英

Eclipse not stopping at java breakpoints during remote debug

I'm running into a really strange error when trying to debug an application deployed to a jetty (9.4) server. I followed the instructions here: https://www.eclipse.org/jetty/documentation/jetty-9/index.html#advanced-debugging for setting up remote debugging with eclipse.I added the debugging arguments to my startup script and if I make a status call on jetty I can see them listed:

RUN_CMD = /opt/java/8/bin/java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999 -Djetty.home=/opt/jetty/9.4 -Djetty.base=/opt/web/jetty -Djava.io.tmpdir=/opt/jetty/temp -jar /opt/jetty/9.4/start.jar jetty.http.host= my ip adr jetty.http.port= my port jetty.spdyPort= my spd port jetty.state=/opt/web/jetty/jetty.state jetty-started.xml

If I run my start script it will pause and wait for me to launch the eclipse debugger before continuing. If I navigate to my app in the browser, I can see from the log output that my methods are running. However, breakpoints inside those methods are never getting hit and the execution never pauses.

I have tried everything I can think of and I just cannot see what I am doing wrong here. I've done this before and it worked, so I can only assume it is something about the way my application is deployed to jetty. Any suggestions would be appreciated.

UPDATE: I have narrowed down what I think is the source of the problem, but I still don't know how to fix it. I recently switched the logging module for jetty from log4j to logback. As soon as I disabled the logback module the debugging worked again. Unfortunately, simply disabling logging is not a long term solution. I still need some way of being able to debug AND have logging enabled.

Thanks to the jetty community I was finally able to track down an answer. See this thread: https://github.com/eclipse/jetty.project/issues/7299 for more details, but the short answer is that it was a jvm forking issue, similar to the question murtiko suggested.

Using any logging framework other than the basic slf4j-impl causes a jvm fork and requires a different approach to make the debugging work. Rather than specifying the debug arguments (-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999 ) in the staup script, they need to be set in the start.ini along with the --exec flag. something like:

# --------------------------------------- 
# Module: logging-logback
# Configure jetty logging to use Logback Logging.
# SLF4J is used as the core logging mechanism.
# --------------------------------------- 
--module=logging-logback

--exec
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999 

If you don't want to have to edit the start.ini every time you want to turn debugging on or off, you can create a custom jetty module instead. I created a file called remote-debug.mod in $JETTY_HOME/modules with the contents

[exec]
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999

To enable debugging I simply have to add the argument --module=remote-debug to the startup command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM