How to debug a JSP tomcat service using eclipse?

前端 未结 4 1685
闹比i
闹比i 2021-02-15 14:21

I would like to debug my separately running JSP/Struts/Tomcat/Hibernate application stack using the Eclipse IDE debugger. How do I setup the java JVM and eclipse so that I can s

相关标签:
4条回答
  • 2021-02-15 14:51

    Follow these steps:

    1. Add the following arguments to the java command that is used to launch Tomcat (on Windows, I think this is in TOMCAT\bin\catalina.bat)

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

    2. In Eclipse, create a 'Remote Java Application' debug configuration and set the port to 8787 and the host to the name (or IP address) of the machine where Tomcat is running. If Tomcat is running on the same machine as Eclipse, use 'localhost'.

    3. In the 'source' tab of the debug configuration, add any projects that you want to debug into

    4. Start Tomcat

    5. Launch the debug configuration you created in step 2

    6. Eclipse should now stop at any breakpoints that you've set in the projects you added in step 3.

    Notes:

    • You can change the port to any other available port if for some reason you can't use 8787
    • If you want Tomcat to wait for the remote debugger to start, use 'suspend=n' in the command above to 'suspend=y'
    0 讨论(0)
  • 2021-02-15 15:04

    I just Googled it. :)

    http://bugs.sakaiproject.org/confluence/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging

    Many more on google.

    Effectively, set your JPDA settings: set JPDA_ADDRESS=8000 set JPDA_TRANSPORT=dt_socket bin/catalina.bat jpda start

    Then, in Eclipse, Run->Debug Configurations...->Remote Applications.

    0 讨论(0)
  • 2021-02-15 15:04

    You could do what they suggest, or use this Eclipse plugin, which makes it easier to configure Tomcat to begin with: Eclipse Tomcat Plugin

    When launching tomcat via this plugin, it starts in debug mode by default, you must explicitly disable debugging mode if you want it to not allow Eclipse to connect a remote debugger.

    0 讨论(0)
  • 2021-02-15 15:04

    For Tomcat 5.5 on Windows:

    Edit bin/startup.bat

    Find the line that reads:

    call "%EXECUTABLE%" start %CMD_LINE_ARGS%

    Replace it with these lines:

    set JPDA_ADDRESS=8000
    set JPDA_TRANSPORT=dt_socket
    call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
    0 讨论(0)
提交回复
热议问题