67

How do you configure JBoss to debug an application in Eclipse?

sblundy
  • 60,628
  • 22
  • 121
  • 123
Etam
  • 4,553
  • 10
  • 40
  • 60

6 Answers6

105

You mean remote debug JBoss from Eclipse ?

From Configuring Eclipse for Remote Debugging:

Set the JAVA_OPTS variable as follows:

set JAVA_OPTS= -Xdebug -Xnoagent 
   -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%

or:

JAVA_OPTS="-Xdebug -Xnoagent 
  -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n $JAVA_OPTS"

In the Debug frame, select the Remote Java Application node.

In the Connection Properties, specify localhost as the Host and specify the Port as the port that was specified in the run batch script of the JBoss server, 8787.

JBoss Debug

Beryllium
  • 12,808
  • 10
  • 56
  • 86
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Not sure if adding a comment to an answer this old will get read but here goes anyway! I've used this setup to debug apps on my JBOSS server through Eclipse and it's working fine - I can set breakpoints in Eclipse and intercept requests on the server. However, when I re-build an app and hot-deploy it onto JBOSS, the new version of the app runs sucessfully but I can no longer intercept the processing through Eclipse. The breakpoints are ignored. Is this expected behaviour? Do I have to re-start JBOSS each time I want to debug a re-deployed app? – CodeClimber Oct 27 '10 at 16:11
  • 1
    @dairemac: it will at least be read by me;) Thank you for this feedback. I don't have the possibility to reproduce directly this specific setting, but I suspect the process monitoring the apps gets terminated during the hot-deploy, which would mean restarting the JBossDebug session. – VonC Oct 27 '10 at 16:42
  • @VonC: I have made the changes in the run.bat file and am trying to restart the jboss server but it is taking hell lot of time as compared to normal mode, any suggestions as to what might improve the bootup time? – Rachel Oct 28 '11 at 21:17
  • 1
    @Rachel: I don't have recent experience with that setup, so any number of parameters can play into this (memory, jdk version used, java options, ...). I would first try monitoring what resource is taking time (IO, blocked port, some kind of timeout?) through a tool like procmon (http://technet.microsoft.com/en-us/sysinternals/bb896645). – VonC Oct 28 '11 at 22:12
  • 1
    I was setting it up in jboss 4, faced a few problems while setting JAVA_OPTS variable. So adding my solution as a comment : Set the JAVA_OPTS variable in bin/run.bat(for windows) or in bin/run.sh(for mac and linux) – ishanbakshi Mar 10 '16 at 00:13
14

VonC mentioned in his answer how to remote debug from Eclipse.

I would like to add that the JAVA_OPTS settings are already in run.conf.bat. You just have to uncomment them:

in JBOSS_HOME\bin\run.conf.bat on Windows:

rem # Sample JPDA settings for remote socket debugging
set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

The Linux version is similar and is located at JBOSS_HOME/bin/run.conf

xdhmoore
  • 8,935
  • 11
  • 47
  • 90
14

If you set up a JBoss server using the Eclipse WebTools, you can simply start the server in debug mode (debug button in the servers view). This will allow you to set breakpoints in the application that is running inside the JBoss.

Fabian Steeg
  • 44,988
  • 7
  • 85
  • 112
  • That is true, and in doubt (since I do not know if this is about remote or local debugging): +1 – VonC Feb 05 '09 at 15:21
1

Here, if you want to directly debug the server then you can use:

1.)Windows ->

2.)Show View -> Server: Right click on server then run In debug mode.

Tom11
  • 2,419
  • 8
  • 30
  • 56
Ankit
  • 593
  • 4
  • 12
0

You need to define a Remote Java Application in the Eclipse debug configurations:

Open the debug configurations (select project, then open from menu run/debug configurations) Select Remote Java Application in the left tree and press "New" button On the right panel select your web app project and enter 8787 in the port field. Here is a link to a detailed description of this process.

When you start the remote debug configuration Eclipse will attach to the JBoss process. If successful the debug view will show the JBoss threads. There is also a disconnect icon in the toolbar/menu to stop remote debugging.

Ankit
  • 593
  • 4
  • 12
0

What @VonC says is correct, but you can put the commands to set debug directly into VM arguments on jBoss Launch.

To do that, open jBoss server inside Eclipse, go to Open launch configuration and put this in VM arguments textbox: vm args

Jaymin Panchal
  • 2,797
  • 2
  • 27
  • 31