32

Past scenario
- Work with Tomcat and start in debug mode and Remote Debug with Eclipse.
- Define a port and connect with eclipse in this debug/remote port.
- Use to debug servers in other hosts/servers

Today scenario
Now, I'm using Jetty and I've try to do the same, but with no success, could anyone help-me with that?
I did not use Maven, and did not want to start Jetty inside from my Eclipse.

Environment:
Windows XP
Java V. 5
Jetty V. 6.1.15

Links:
http:// docs.codehaus.org/display/JETTY/Debugging
This did not help me!
http:// docs.codehaus.org/display/JETTY/Debugging+Jetty+with+Eclipse
http:// neelzone.wordpress.com/2007/06/18/jetty-and-eclipse-integration
These are to start inside Eclipse

rafa.ferreira
  • 1,997
  • 7
  • 26
  • 41

4 Answers4

38

This is what we are adding to our JBoss command line while development:

-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

Then we launch the eclipse remote debugging and connection to this port.


Update:

To run from jar (standalone) do the following

java -Xdebug -Xrunjdwp:transport=dt_socket,address=8585,server=y,suspend=n -jar start.jar 
Nishant
  • 54,584
  • 13
  • 112
  • 127
David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125
  • 2
    Just a minor nitpick: that syntax is for pre-1.5 JVMs, newer ones use the -agentlib:jdwp option. – andri Jul 06 '09 at 19:23
  • 2
    Hey David, thanks for your answer, works for me. I'm using the fallow command to start my Jetty: java -Xdebug -Xrunjdwp:transport=dt_socket,address=8585,server=y,suspend=n -jar start.jar Thanks! – rafa.ferreira Jul 06 '09 at 20:39
18

For remote debugging you should use JPDA. There's a sort of tutorialish article about it available here.

In short, start your JVM with the argument:

-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n

and you are able to connect to the underlying JVM listening on port 8000 via the standard Eclipse debugger.

Community
  • 1
  • 1
andri
  • 11,171
  • 2
  • 38
  • 49
15

If you will use mvn jetty:run one day, you have to

export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"

appending -Xdebug ... doesn't works

Maciek Kreft
  • 882
  • 9
  • 14
0

Using the JVM "agentlib" command-line parameter before "start.jar" did not work for me, but this does:

How to allow Eclipse to remotely debug #Jetty (#JPDA #agentlib:jdwp) on port 8000

You have to create a file, $JETTY_BASE/start.ini (do not change $JETTY_HOME/start.ini) and put the following two lines in it:

  • --exec
  • -agentlib:jdwp=transport=dt_socket,address=localhost:8000,server=y,suspend=n
Malcolm Boekhoff
  • 1,032
  • 11
  • 9