Download presentation
Presentation is loading. Please wait.
Published byMarta Arnold Modified over 6 years ago
1
Aaron Zeckoski azeckoski@gmail.com
Tomcat Debugging Aaron Zeckoski
2
Why bother with a debugger?
Allows tracing of unfamiliar code Learning process Reduces the busywork involved with adding in lots of logging System.out.println Log.debug Allows ability to see what is going on in code outside your control
3
Programmers Cafe Instructions for setting up tomcat debugging are available on the café website
4
Tomcat JPDA Java Platform Debugger Architecture
Tomcat can be configured to allow a program such as eclipse to connect remotely and see debugging information Simply need to add a command line option jpda start (possibly debug in older versions) WIN: set JPDA_ADDRESS=8000 set JPDA_TRANSPORT=dt_socket bin/catalina.bat jpda start UNIX: export JPDA_ADDRESS=8000 export JPDA_TRANSPORT=dt_socket bin/catalina.sh jpda start URL:
5
Adjusting the tomcat startup script
This is an easy way to always have your server listening for a debugger connection Add the following environment variables at the beginning of your startup script Adjust the startup line at the end of the script set JPDA_ADDRESS=8000 set JPDA_TRANSPORT=dt_socket WIN: call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS% UNIX: exec "$PRGDIR"/"$EXECUTABLE" jpda start
6
Configuring eclipse Eclipse can be configured to provide debugging information for a running tomcat instance that is configured with JPDA support You will need to have tomcat setup first URL:
7
Setup Eclipse Tomcat Debugging
Under the "Run" menu, select "Debug…" Double-click the heading "Remote Java Application“ to create a new configuration Enter a meaningful name for this configuration (e.g. sakai_tomcat_debug) Change to the "Source" tab, then click "Add" Click "Java Project", then click "OK" Click "Select All“, then click "OK" (or check the projects you wish to import) Click the "Connect" tab and check the box marked "Allow termination of remote JVM" Click "Apply" to save your changes
8
Using Eclipse to Debug Sakai
Set a breakpoint somewhere in your code (preferably something not associated with startup) by left-clicking to the left of a line of code Click on the debug icon at the top (looks like a little bug) to start debugging Might need to click the down arrow and select your sakai debugging config Click through the app in a browser until your breakpoint is reached Focus will shift to the debugger automatically
9
Eclipse Debugging Lots of tutorials available online In a nutshell
Use google search! In a nutshell create breakpoints Use the step-into, step-over, etc… to navigate through the code Use Resume to start running code again Disconnect to break the debug connection Stop to shutdown tomcat
10
More tomcat stuff Can redeploy your sakai apps in tomcat
Just run maven sakai from within the tool directory of most any sakai app project Cannot redeploy the services though If you run maven sakai from within the service directory or with the root of a project while tomcat is running then Sakai will die horribly Just restart tomcat and everything will be ok again
11
Windows Webapp redeployment
Windows locks the files and jars in tomcat so that it is difficult to redeploy webapps Overcome this limitation by adding the antiResourceLocking and antiJARLocking attributes to your base context file context.xml ($CATALINA_HOME/conf/context.xml) <!-- The contents of this file will be loaded for each web application --> <Context antiJARLocking="true" antiResourceLocking="true" > <!-- Default set of monitored resources --> … URL:
12
Questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.