Debug breakpoint Debugging for a Tomcat project under MyEclipse

Source: Internet
Author: User

For Eclipse or MyEclipse debug J2SE project or small application for breakpoint debugging, everyone is not unfamiliar, as long as the breakpoint set, debug run OK. But if it is a Web project, and the project is running in the container, such as Tomcat,resin, and so on, some students do not know how to debug breakpoints, can only take this method, is the use of System.out.println () printing method, which is not good, and waste a lot of time. The following summarizes the methods for debugging Web projects under MyEclipse under breakpoints.

Get ready

Environment: windxp,jdk1.6,myeclipse10.7,tomcat6.0.37

MyEclipse build the Web project Servlettest, and then create a testservelet.java that is not modified by the auto-generated code because it is used for testing.

Set a breakpoint on Testservlet.java

Look at the web.

[HTML] view plain copy  
  1. <? XML version= "1.0" encoding="UTF-8"?>
  2. <Web-app version="3.0"
  3. xmlns="Http://java.sun.com/xml/ns/javaee"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee
  6. Http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd ">
  7. <display-name></display-name>
  8. <servlet>
  9. <description>this is the description of my EE component</description>
  10. <display-name>this is the display name of my EE component</display-name>
  11. <servlet-name>testservlet</servlet-name>
  12. <servlet-class>com.fei.servlet.testservlet</servlet-class>
  13. </servlet>
  14. <servlet-mapping>
  15. <servlet-name>testservlet</servlet-name>
  16. <url-pattern>/servlet/testservlet</url-pattern>
  17. </servlet-mapping>
  18. <welcome-file-list>
  19. <welcome-file>index.jsp</welcome-file>
  20. </welcome-file-list>
  21. </Web-app>


All right, get ready for work.

Local debugging

Local debugging is the tomcat that is set to start in MyEclipse and has been started in debug mode. This is simple and does not require additional work.

1. Set up Tomcat

Window->preferences->myeclipse->servers->tomcat

Setting the startup mode

Deployment Project

Start the service

Browser input Address: Http://localhost:8080/servlettest/servlet/TestServlet

MyEclipse switch to debug view, here everyone is not unfamiliar.

Remote debugging

Remote debugging, is relative to MyEclipse, is that Tomcat is not started in MyEclipse, but to start the external itself, or tomcat running on another server, not and myeclipse the same computer. In the above local debugging, the most important thing is that Tomcat boot mode is set to debug mode, so for remote debugging, Tomcat must be in debug mode to boot, and then MyEclipse and Tomcat to set up the connection.

Open the Tomcat bin directory and find Catalina.bat and Startup.bat copy, named Catalina_debug.bat,startup_debug.bat.

Open Startup_debug.bat and precede the phrase "current_dir=%cd%" with the following:

Set jpda_address=8000
Set Jpda_transport=dt_socket
Set Catalina_opts=-server-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,server=y,suspend=n, address=8000

The above debug listening port 8000 can be replaced with unused ports

At the same time, the Catalina.bat in the text is replaced with Catalina_debug.bat.

Open the Catalina_debug.bat, and precede the set "current_dir=%cd%" with

SET Catalina_opts=-server-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,server=y,suspend=n, address=1861

Double-click Startup_debug.bat to start Tomcat.

The configuration of the MyEclipse.

Right-click on the item and follow the actions shown

Check if you are listening, open the debug view

Browser input Address: Http://localhost:8080/servlettest/servlet/TestServlet

You can debug the normal breakpoint!!!

Debug breakpoint Debugging for a Tomcat project under MyEclipse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.