I sometimes work on web application code that I test by deploying into a Tomcat servlet container. I develop on Ubuntu-based systems, and like to use the tomcat7-user (and/or tomcat8-user) package for testing. I believe this package is also available on Debian systems.
$ sudo apt-get install tomcat7-user
Once installed, a new command is available for creating local Tomcat instances. It saves me from dealing with a globally configured Tomcat server on my system:
$ tomcat7-create-instance my-tomcat $ cd my-tomcat/bin $ ls setenv.sh shutdown.sh startup.sh $ cat startup.sh #!/bin/sh export CATALINA_BASE="/home/dale/my-tomcat" /usr/share/tomcat7/bin/startup.sh echo "Tomcat started"
Of course, the CATALINA_BASE value in your script will be slightly different. Sometimes I want the ability to connect an interactive debugger to my application’s running server-side code. The provisioned startup script doesn’t provide an easy way to enable JPDA so that I can do this. Let’s create a script that will:
$ cp startup.sh debug.sh
Use your favorite editor to modify debug.sh so it looks as follows:
#!/bin/sh export CATALINA_BASE="/home/dale/my-tomcat" /usr/share/tomcat7/bin/catalina.sh jpda start echo "Tomcat started in debug mode"
I use Eclipse as my development environment. If you do, too, then you can follow the useful guide at http://blogs.mulesoft.org/debugging-your-tomcat-webapp-with-eclipse/ to connect the interactive debugger to your application.