score:31

Accepted answer

in the <java> ant task you should add two jvm parameters (<jvmarg> iirc) to turn on debugging:

 -xdebug -xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5432

this will launch the java program with debugging turned on and the program will be ready to accept debugger connections on port 5432. then you should use your ide's remote debugging facility and direct it to connect to port 5432.

score:0

i too faced this problem, i did following steps to resolve.

  1. put the below lines in ant file

  2. go to the debugging configurations->remote java application-> create new configuration file with project name,port=5432 and host is localhost and save it.

  3. now run your build.xml using debugging mode, then you should see in console that "listening for transport dt_socket at address 5432"

  4. now run debug configuration file which is you configured. now your selenium code will run using debug mode.

hope this helps.

if you still facing issues, please let me know so that i can help you on that.

thanks

score:1

steps:

1)configure remote java debugger with local host as name, port address as 8000(or whatever your system's port address will be)

2)create a batch file and keep that in bin folder of your tomcat(this step is required when we want to debug remotely keeping server/s in same system).

in batch file you should keep this line:

set jpda_address=8000

set jpda_transport=dt_socket

catalina.bat jpda start

after this keep a break point in your java code, and debug this remote debugger. it will work.

happy coding !!

score:2

this is to help the people who are wondering how to debug the web application that use ant to build and deploy. this is quite frequent in legacy applications. if the project was started as "dynamic web project" as the beginning, following steps and even ant is not necessary.

set the break point in your code.

window -> show view -> others -> servers

add your server jboss or tomcat for example.

right click on the server and choose 'debug'.

make sure that debug="true" is set in ant build file.

score:2

set ant_opts=%ant_opts% -xdebug -xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5432

in eclipse

toolbar >> run >> debug configurations >> + >> 

give the values:

name: debug_ant
project: active-eclipse-project
host:localhost
port:5432

score:3

this is how i got it working for me (just commenting for future reference).

link dump ahead :


debugging ant tasks is not as simple as plain old java debugging. while you can debug an ant file adding breakpoints, digging inside the code of specific custom task will require you to add a remote debugger in order to be able to "catch" the running process.

i will explain how to do this in eclipse, altough i recon it can be achieved with all major java ides. first thing is to create a new run configuration for the ant file where you plan to use your customized new task. to do so, go to:

run -> external tools -> external tools configuration...

right click in ant build -> new and in the main tab select your ant script in buildfile field. then go to jre tab and insert the following jvm arguments:

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

if you wonder what these arguments mean check this, although a bit updated (java 1.5) still works.

once this is done, you must create a new debug configuration for a remote java application. to do so, navigate to:

run-> debug configurations

drop down the list in the left column and right click in remote java application -> new. select the project name in the project field. default values for host and port are okay as long as you used the same ones for the ant configuration (jvm arguments).

everything is ready for the test run! add breakpoints wherever you consider necessary. in my case, i added one both in the ant script that uses the custom ant task as well as in the custom ant task, in the execute method.

right click in your ant script or task -> debug as...-> ant >build first

now before calling your custom ant task code, go to run-> debug configurations and debug your previously created java remote application config. this will start a separate thread that will debug your custom ant task code, provided that you included some breakpoints :) you can see in the following image how in my case, thread stopped in the execute method of my custom ant task. after this point, it is up to you to decide what to do next...

score:5

in eclipse:

toolbar > external tool configurations... > (select your existing ant build or create new) > jre tab

in "vm arguments" add:

-xdebug -xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

again toolbar > debug > debug configurations... > remote java application > new

name: debug ant
project: <select your project where debug files are kept>
host: localhost
port: 8787

now in "external tool configurations" launch "ant task" (which waits for the remote java application debugger to connect), then launch the "debug ant" from the "debug" toolbar icon.

score:51

(wasn't able to comment on the given answer, so have to make another answer)

i realized that when launching ant from eclipse, you'll have to add fork="true" to the <java> task. also, it was first not clear to me how to write nested jvmargs, so here goes an example:

<java classname="..." fork="true">
  <jvmarg value="-xdebug" />
  <jvmarg value="-xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5432" />
  ...
</java>

Related Query

More Query from same tag