Andrej Koelewijn

10/23/2003

Using eclipse to debug your tomcat web application

Filed under: — andrejk @ 11:27 am

Got this question again today. Usually i’d say: use the tomcat plugin, but in this case tomcat 3.2.4 is used, as that’s the tomcat version the web server is still using. The eclipse tomcat plugin only supports tomcat 3.3 and up.



Here’s what you do:


  • Start java with remote debugging enabled. You do this by modifying tomcat.bat (assuming you’re on windows). You have to add some parameters when starting java. If you start tomcat from a cmd box, look for the line “echo Starting Tomcat in new window” in tomcat.bat. Add the following line:
    set JAVA_X_OPTS=-Xdebug -Xnoagent
    -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5000

    And modify the star t java line as follows:
    _STARTJAVA TOMCAT_OPTS -Dtomcat.home="TOMCAT_HOME"
    org.apache.tomcat.startup.Tomcat %2 %3 %4 %5 %6 %7 %8 %

    Now you can start tomcat by typing startup.bat in your cmd box.

  • Click on the debug button in your eclipse toolbar. Select the “Debug…” item. This will open a debug window. Under configurations you’ll find an entry “Remote Java Application”. Select this and then press the new button. Choose a project, leave the connection type to “standard (socket attach)” and for connection properties choose “localhost” and “5000” (change these if you’re using a different port or a different machine to run tomcat). Now press apply and debug.




That’s it. You can now set breakpoints in your code, and inspect what your application is doing.

50 Responses to “Using eclipse to debug your tomcat web application”

  1. mucher Says:

    Works like a charm, I’m using this myself.

    But can’t the sysdeo plugin debug the 3.x Tomcat versions?

  2. Andrej Says:

    Only 3.3, not 3.2. I got a class not found error when trying to debug 3.2.

  3. wei Says:

    How about JSP? Can we do it this way?

  4. Matt P Says:

    Thanks, for the tip

  5. andrej Says:

    You cannot debug jsp’s using this technique. You may be able to debug the java files generated for the jsp files, but probably only if the directory your tomcat application context is pointing to, is the directory where you develop your application (i.e., not if you are deploying a war file). But i’ve never tried this, so it may not work.

  6. bioye Says:

    hi,

    i am using tomcat 5.0.16 final. what is the best way to debug my web application? including the jsp and the bean classes? an early answer will be appreciated.

    thanx.

  7. Andrej Says:

    Take a look at the lomboz plugin for eclipse. It supports jsp debugging. Matt raible has packaged it for eclipse 3.0 M8, with some other usefull plugins: http://raibledesigns.com/page/rd?anchor=eclipse_plugins_updated_for_3

  8. mahesh adepu Says:

    Hi, I want to know how to debug a Jsp from eclispe 3.0 or eclipse 2.1.3 on Jboss-3.2.4

  9. Andrej Says:

    As mentioned in the previous comment, you can use matt raible’s plugin, or you can use myeclipse (http://www.myeclipseide.com/). The sysdeo tomcat plugin (http://www.sysdeo.com/eclipse/tomcatPlugin.html) also supports jsp debugging (not very user friendly, but it seems to work).

  10. mahesh adepu Says:

    Thanks for your prompt reply but i am using jboss 3.2.4.
    In jboss 3.2.4,tomcat 5 is integrated.So there is a problem in setting up the configuartion for sysdeo tomcat plugin like setting tomcat home and server.xml.Just i want a plugin or anything that will provide good debugging facility for java classes,struts and jsps.And iam very thankfult to you,if you give any example for debugging also.As i am beginner to eclipse and other plugins.Please give me detailed step by step procedure.
    Thanking you.
    mahesh

  11. mahesh adepu Says:

    Hi Andrej,can you give quick reply to previous comment.
    mahesh

  12. Andrej Says:

    I have no experience with the exact versions you mention. Have you looked at myeclipse? Another option is to download jdeveloper from OTN (http://otn.oracle.com/). Jdeveloper has good jsp debugging support.

  13. mahesh adepu Says:

    Hi Andrej,once again thanks for your reply.From eclipse i am building my web application archive(exploded war) file through my bulid.xml.I also integrated jboss-3.2.4 into my eclipse 3.0.Then i am starting jboss server in debug mode.
    But i have no idea how to trace java classes and jsp in running web module.
    And one more thing is how to integrate struts plugin into eclipse 3.0.I tried to install easystruts plugin but its asking for org.eclipse.pde.ui.But where as in my eclipse plugin directory org.eclipse.pde.ui_3.00 is there.
    I hope now you clearly understood my problem.
    Thanking you.
    mahesh

  14. Rajendra Says:

    Well, I hv one problem below in deploying application on tomcat. pls.. do needful for me.
    I m getting The requested resource (/Assignment/Assign/welcome.jsp) is not available. error.

    I am trying simple example to know how MVC work. I m using Eclipse 2.1 IDE n Tomcat 5.0.
    I hv configured Tomcat, set all paths i.e. JAVA_HOME, JRE_HOME, CLASSPATH, CATALINA_HOME, all things set in Eclipse prefeference. My web application folder name is Assignment in which i hv one directory Assign. On the root of directory i hv all xml including web.xml. I hv written welcome.jsp on root n my web.xml contains
    (here frame work is webwork.)

    Hi

    webwork
    com.opensymphony.webwork.dispatcher.ServletDispatcher
    1


    webwork
    *.action


    welcome.jsp


    webwork
    /WEB-INF/lib/webwork-2.1.jar


    404
    /error.jsp


    all jars are included on web server and WEB-INF/lib folder. Action class is in Assign folder.

    All things r well set. Tomcat is running. I m requesting http://localhost:8080/Assignment/Assign/welcome.jsp it gives me welcome.jsp not found error and following exception in tomcat javax.management.MalformedObjectNameException,
    BindingException.

    Another thing i want to know textfields, combo values are mapped to action class fields.

    Thanks & Regards,

    Rajendra

  15. Ann Says:

    I am running pretty vanilla Tomcat 5 fine standalone. I have SYSDEO plugin in Eclipse and can start and stop Tomcat. I get “Failed to connect to remote VM” when I try to run debug. None of the text above appears in the Catalina bats and xmls. I really would appreciate the dummies version.

  16. Ahmed Says:

    The progress bar hangs on 91%
    I have Tomcat 4.1.30 Service on the same machine
    Eclipse 3.0
    Windows XP Home SP1

  17. Bandale Gajanan K Says:

    Sir, can u tell me the prodedure for running tomcat in eclipse. I am using Tomcat 5.0 and Eclipse 3.0 i installed Sysdeo Plugins for tomcat but how to run tomcat within eclipse. Please help me to solve the above query. Please give prodedure.
    Awaiting for your reply.
    Thanx

  18. Sree Vidhya Says:

    Sir,
    i have Win’98 in my pc.i want to work on j2ee.so i need jboss-3.2.4 or oc4j and a editor and i prefer eclipse.can u suggest me a site whr i can download all these free of cost
    Thanking u

  19. andrejk Says:

    Try google, all of these tools are available for download. It shouldn’t be hard to find the sites where you can download them.

  20. sasi Says:

    I am using tomcat 4.1 and there is no tomcat.bat in bin folder
    can u plz tell me the procedure for starting tomcat 4.1 in debugging mode

  21. Mir Says:

    Hi,

    I am also facing the above mentioned problem. In tomcat 4.1, there is no tomcat.bat file in the folder bin. So, what to do to start the Server from DOS prompt? Can anybody give a prompt reply?

  22. renbing Says:

    about debuging JSP with tomcatPlugin:

    in your tomcat project, find the directory named “work”, and you can find the servelet corresponding to the JSP there. debug the servlets.

  23. ravi Says:

    how can run one folder that contains all jsp’s and servlets,
    with tomcat5.x and eclipse3.1 ide tool.

  24. Anonymous Says:

    Hello,
    I want to debugg jsps and beans using eclips.using ur website
    I found that there are 3 ways to that.
    1)Resin plugin
    2)MyEclipse plugin
    3)sysdeo plugin

    can u plase tell me the differences amoung them and which is better plugin

  25. Digant Says:

    Hi !

    I have eclipse-sysdeo question.
    I have tomcat project with SysDeo plug-in in eclipse 3.1.1
    I was able to set breakpoint in servlet code ( struts Action), I refactored name of eclipse project to diffrent name
    Now I can’t see execution step in Debug view.
    Do you know what I have to set to see step debugging ?
    Thanks.
    Digant

  26. Valerie Says:

    I am trying to accomplish remote debugging of a Java application using Eclipse 3.1 and Tomcat 5.5 on Windows platforms. I have made all the suggested modifications to Catalina.bat file and ran the bat file on the server containing the war file using Port 8000. On launching the application from Eclipse I get the message “Failed to connect to remote VM”. The network web server is located behind an F5 and port forwarding is enabled and I believe this is my problem. Does anybody have any information relative to remote debugging a java application on an F5 network using port forwarding? Thanks for any help

  27. Dan Says:

    I’ve used tomcat and I’ve never really had this problem.

  28. Vinod Says:

    Hi Andrej ,

    With ur permission.. I am adding this link, provide the info for
    debugging with eclipse.
    http://jroller.com/page/gursesl/cleanfulltext/remote_application_debugging_with_weblogic#eclipse

  29. David Says:

    I wish to do remote debugging of a Tomcat 3.3 (and Java 1.3) application via eclipse 3.1.2
    Constraints of the project force me to use an older version of Tomcat. I already know that it is not possible to set up Tomcat 3 as a server project within eclipse. How do I fill in the Run/Debug/Remote Application configuration? I’ve tried with both Port 5000 and Port 8000 but I get a “Failed to Connect to VM message”
    Thanks,
    David
    dziants@gmail.com

  30. Jude Says:

    I am getting the following in eclipse 3.0 console. What I mean that the “Debug output” is being redirected to the screen,

    DEBUG [http-8080-Processor24] (ApplicationDispatcher.java:148) – servletPath=/jsp/login/ValidateLogin.jsp, pathInfo=null, queryString=null, name=null
    DEBUG [http-8080-Processor24] (ApplicationDispatcher.java:564) – Path Based Include
    DEBUG [http-8080-Processor24] (ApplicationDispatcher.java:148) – servletPath=/Delegate, pathInfo=null, queryString=ACTIONKEY=UserContextAction.setupProjectList&REDIRECTKEY=login/ProjectList, name=null
    DEBUG [http-8080-Processor24] (ApplicationDispatcher.java:381) – Path Based Forward
    DEBUG [http-8080-Processor24] (ApplicationDispatcher.java:148) – servletPath=/jsp/login/ProjectList.jsp, pathInfo=null, queryString=null, name=null
    DEBUG [http-8080-Processor24] (ApplicationDispatcher.java:564) – Path Based Include
    DEBUG [http-8080-Processor24] (ApplicationDispatcher.java:418) – Disabling the response for futher output
    DEBUG [http-8080-Processor24] (ApplicationDispatcher.java:426) – The Response is vehiculed using a wrapper: org.apache.catalina.core.ApplicationHttpResponse
    DEBUG [http-8080-Processor25] (ApplicationDispatcher.java:148) – servletPath=/jsp/MenuIndex.jsp, pathInfo=null, queryString=null, name=null
    DEBUG [http-8080-Processor25] (ApplicationDispatcher.java:564) – Path Based Include
    DEBUG [http-8080-Processor25] (ApplicationDispatcher.java:148) – servletPath=/jsp/MenuHeader.jsp, pathInfo=null, queryString=null, name=null
    DEBUG [http-8080-Processor25] (ApplicationDispatcher.java:564) – Path Based Include
    DEBUG [http-8080-Processor25] (ApplicationDispatcher.java:148) – servletPath=/jsp/dashboard/QuickSearch.jsp, pathInfo=null, queryString=null, name=null
    DEBUG [http-8080-Processor25] (ApplicationDispatcher.java:564) – Path Based Include

    Can anyone suggest how to stop the “Debug output” from being redirected to the console.

  31. vikram Says:

    hi, i too have the similar kind of problem , i used tomcat plugin in eclipse and when i attempts to start tomcat its going to debug mode how to solve this

  32. siva shanker Says:

    now i want to find how to debug using tomcat5.5 apllication by using eclips3.2

  33. nate Says:

    does anyone know how to register tomcat 5.5 with eclipse 3.2
    i do not have options for tomcat…

    thanks

  34. sangam Says:

    send detail procedure for debugging and how to process break points

  35. Jon Says:

    Digant said:
    >I have tomcat project with SysDeo plug-in in eclipse 3.1.1
    >I was able to set breakpoint in servlet code ( struts Action)
    >Now I can’t see execution step in Debug view.

    I’m experiencing a similar error. I can see the progress of the program in the debug window, but Eclipse does not synchronize the code window nor highlight the currently executing line. Has anyone experienced anything similar?

  36. Jon Says:

    A solution: in the Tomcat add-in settings, click “Source Path.” Uncheck “Automatically Compute Source Path”, and check the projects you wish to debug.

    Seems obvious in retrospect.

  37. kavitha Says:

    I am using eclipse3.1
    and I want to run struts applications using tomcat
    I downloaded tomcatplugin but I am not able to find the tomcat icon on the eclipse editor
    will you please help me

  38. Santiago Says:

    Thanks Jon!!!
    I almost got crazy trying to fix that!!
    Thanks for sharing that info!!
    Regards
    Santiago

    Jon Says:
    July 18th, 2006 at 9:00 pm

    A solution: in the Tomcat add-in settings, click “Source Path.” Uncheck “Automatically Compute Source Path”, and check the projects you wish to debug.

    Seems obvious in retrospect.

  39. custom website design Says:

    Hey

    I am using tomcat but Eclipse tool will work only for one month and again we have to format.will u give the solution for this.But this tool is nice yaaaaaaaaar

  40. tulasi Says:

    Hi,

    how to view console of tomcat 5.5. I am using Logging (Log4j),

    but i am not able to see console of tomcat 5.5

    will u plz help me

    ThanQ

  41. raghu Says:

    hi ihave no idea about eclipse3.1.2.how to run the sevelets programs in elipse.and how to add the plugins(server) in eclpise .i don’t reuired or not(add plugins in eclipse).

  42. vipul Says:

    HOW CAN I PLUG IN WITH ECLIPS FOR TOMCAT

  43. trying hard ! Says:

    Jon thanks a lot !! It works.

    Do everything that is suggested. ( Just start the tomcat using the buttons in eclipse)

    create a new remote debugger as suggested above.

    and in tomcat – source path: select the project folder which you want to debug. thats it !!

  44. Levent Gurses Says:

    Hi Vinod/Anrej,

    The remote debugging article has moved to

    http://www.jacoozi.com/index.php?option=com_content&task=view&id=119&Itemid=134

    Please update your bookmarks. Thanks.

  45. Tejas Chachcha Says:

    In tomcat 5.0 tomcat.bat is renamed as catalina.bat.. and JAVA_X_OPTS is renamed to JAVA_OPTS

    just update JAVA_OPTS as per the instructions and set the debug port 5000 in your eclipse (whatever version it is)

    worked for mine..

    Regards,
    Tejas

  46. Kalyan Says:

    Hi,
    Iam using Eclipse3.0.0 Tomcat 5.0. I deployed my project onto Tomcat. Now I want to launch the tomcat and debug using eclipse. I made the following changes to the catalina.bat

    set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

    and created a new configuration of Tomcat debugger. But eclipse throws an error saying unable to connect to VM.

  47. Rajkumar Says:

    Hi

    I installed tomcat 6.0 i want to use struts any one suggest me on this topic. How to configure to run struts using tomcat

  48. Prasad Says:

    I m using eclipse 3.0 .

    I m getting the problem .
    Request is forwarded twice or thrice.
    I have checked the code.
    PLZ help me out.

  49. madhankumar Says:

    hi,

    can anyone guide me how to use eclips? if u have related documents do fwd me. that ll def help me to understand abt Eclips.
    looking for ur g8 favour….....
    regards
    MadhanKumar

  50. Anonymous Says:

    hi ihave no idea about eclipse3.1.2.how to run the sevelets programs in elipse.and how to add the plugins(server) in eclpise .i don’t reuired or not(add plugins in eclipse).

Leave a Reply

Powered by WordPress