When should you use a debugger during development? At ALL times! At least that's my view.
Isn't that a hassle? Well debugging sure can be, but if you setup your environment in a specific way, it can actually become very fast and almost transaprent. I like transparent!
Here are steps I take to configure my tomcat (I've followed the same steps with JBoss):
- Note the deployment path of tomcat (in my case I'll use
- In Eclipse, open the "Run Configurations" manager (Run -> Run Configurations...)
- On the "Java Application" node, right click and choose "New".
- On the first tab (Main) select the project you are running in tomcat
- In the Main Class field enter
- On the Arguments tab, in the Program Arguments field enter
- In the VM arguments field enter the following:
You many notice that I included a reference to my portal project's portal-developer-tomcat.properties file. This way I can change portal settings and only need to restart the portal without a redeploy, which is very convenient.
You may also notice that I included tomcat's juli log manager so that all the normal web app configurations work as expected and in the Eclipse console, which is also very nice.
Adjust your heap settings as desired, but the above settings have worked for me in 99.999% of cases.
- In the Working directory field choose "Other" and enter
/bundles/tomcat-6.0.x/bin. Notice that this is the tomcat path, plus the
- The JRE tab should be already set properly, but you can choose any JRE that is installed that is 1.5+.
- On the Classpath tab, remove any entries under User Entries and then choose "Add External JARs...".
- Select the 3 jars located in
- On the Source tab make sure that you have both Default, as well as your project in the list.
Optionally here you can add any plugin projects that you are working on, as well as adding the path to the jsp java classes (typically
- On the Common tag choose at least Debug and Run under "Display in favorites menu".
- Click "Apply" near the bottom of the dialog.
- Finally, to start the portal in debug mode, click the Debug menu in the Eclipse toolbar, and choose the run config you jsut created.
You should see at this point output on the Eclipse console showing that tomcat is starting up.
I've been using this techinque for at least 3 years and I run the portal this way 99.999% of the time. By doing so, I can at any point in time add a breakpoint and start trouble shooting and I don't have to worry about re-connecting to or restarting the portal in debug mode, I know it's already done.
If you want to add any other java apps this way, the simples technique is to first run the app in the traditional way, then observe the process log to see what the full command that was actually used to start it, and from where. Once you know that, you can add any app to Eclipse Run Configuration.