facebook

[Tomcat] How do you debug Tomcat sources?

  1. MyEclipse IDE
  2.  > 
  3. FAQ – Development
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #259927 Reply

    Riyad Kalla
    Member

    This question is meant to help people that, while debugging, may want to actually step into the Tomcat source files like the Catalina request processors or something along those lines. Long time MyEclipse guru arjan.tijms has posted very detailed steps on how to get this working (for Tomcat 5; later releases may be slightly different) and they are as follows:

    1. Download tomcat sources and extract
    2. The actual source is spread throughout many different directories, collect them all into a single directory (you’ll end up with a javax.servlet.* and an org.apache.*; if you do this often you may wish to create a script for doing this)
    3. Create a new web project and copy the merged tomcat sources to it
      You’ll notice a lot of unmet dependencies. This doesn’t matter as JDT is still able to do its work. If you wish you can satisfy these dependencies by copying libs like commons-collections, commons-logigng etc to this project’s path.
    4. JAR both the sources and compiled classes. In my project I have an ant file in a directory tomcat5.5.17/build_libs, where tomcat5.5.17 is the name of my project. E.g.
      <project name="tomcat" default="doTomcat" basedir="../." >
         
       
        <property name="buildDir"             value="build_libs"                />
        <property name="binSourceDir"          value="WebRoot/WEB-INF/classes/"   /> 
        <property name="srcSourceDir"          value="src/"                  />
         
        <target name="doTomcat" >
           <jar destfile="${buildDir}/tomcat_5_5_17.jar"  basedir="${binSourceDir}"
              includes="javax/servlet/** org/apache/**"
           >    
            
         </jar>
         
         <jar destfile="${buildDir}/tomcat_5_5_17_src.jar"  basedir="${srcSourceDir}"
              includes="javax/servlet/** org/apache/**"
           >    
         </jar> 
              
           <eclipse.refreshLocal resource="tomcat5.5.17/${buildDir}" depth="infinite"/>
                   
        </target>
       
      </project> 
      
    5. In the project where you wish to step into tomcat’s source code, create a directory -outside- of your web root, e.g. [project root]/ext_src (it must be created outside the web root so it doesn’t get deployed).
    6. Copy the tomcat_5_5_17.jar and tomcat_5_5_17_src.jar to this new directory.
    7. In your project settings, add ext_src/tomcat_5_5_17.jar to your Java build path.
    8. While the Java build path dialog is still open, unfold the jar you just added and do a source attachment to the tomcat_5_5_17_src.jar.
    9. You may wish to close the other project where you generated the jars.

    You can now step into the majority of the tomcat source code from your own code. For a few classes the MyEclipse J2EE library container still takes precedence when debugging, notably javax.servlet.jar. Sometimes it helps to attach the tomcat_5_5_17_src.jar to this.

    • This topic was modified 8 years, 8 months ago by support-tony. Reason: Corrected markup
Viewing 1 post (of 1 total)
Reply To: [Tomcat] How do you debug Tomcat sources?

This topic is marked as closed to new replies, however your posting capabilities still allow you to do so.

You must be logged in to post in the forum log in