eclipse debug remote web application

2019-08-25 19:05发布

问题:

I have a struts2 web application developed in eclipse IDE and exported it as war file and deployed it in tomcat7 installed in windows server. Now I need to debug this deployed web application in eclipse inside my local system. How to bring those codes inside? I found some links but I stuck with how to bring those code into eclipse in my local system to place break points.

these are those few links...

link 1 link 2 link 3 link 4

回答1:

Solution for windows:

First you have to modyfy your tomcat startup script (startup.bat):

Put this on top of the startup.bat

set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
...

Then modyfy the following line (nearly at hte end of startup.bat):

call "%EXECUTABLE%" start %CMD_LINE_ARGS%

to

call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

Now you can start tomcat by executing startup.bat and tomcat opens the port 8000 for debuging.

Second step is to configure Eclipse:

Select Run > Debug Configurations ...

Create a new configuration by selecting 'Remote Java Application' with a right click.

Check that the right Project is selected.

And modyfy the Connection properties. (Note that the port has to be same (8000) as entered in startup.bat and not the port on which your struts app is running)

Finaly you have to click on Debug

Now you should be able to set breakpoints.



回答2:

..Or simply navigate to the bin folder and start your tomcat with the following command:

catalina jpda start

No need to make any changes with this approach. The defaults are the same as quoted by Ingemar: port 8000 and transport=dt_socket. Confirmed to work with tomcat 7 (.0.40 or newer to be precise). Then follow his instructions and setup a Remote Java Application debug configuration in Eclipse. Basically, just use the defaults - they match (at least in Juno and Kepler). You might want to check the Source tab or do this on demand while you debug.

... Or, in case you use maven, you might consider the tomcat7-maven-plugin plugin, which will completely keep you inside eclipse.

Happy debugging