This blog is subject the DISCLAIMER below.

Thursday, February 21, 2008

Debugging Tomcat web applications using JDeveloper

Hello All

I managed to enable JDeveloper to debug with tomcat and here are the steps to accomplish that.

As a prerequisite for this, you must have a tomcat server locally installed. I need to note also that this way you won’t be able to debug jsp files (Only classes). Actually there is a way around that but it’s so buggy and tiresome.

First you need to add those lines to the java options in tomcat configuration:

-Xdebug

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

Second, go to the folder where tomcat is installed (for me it is “C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\Catalina\localhost”) and create a file called “project1.xml” for example, and paste this line in it.

project1\ViewController\public_html" path="/project1" reloadable="true" />

Where

docBase is the path to your public_html folder

reloadable=”true” allows tomcat to pickup any changes that you make to your jsps.

Path is the path that you can access your web application through.

Third, you need to create a new run configuration for tomcat (we need a remote debugging configuration):

* Check “Remote Debugging and Profiling”
* Go to Debugger -> Remote and change
o Protocol à Attach to JPDA
o Host à 127.0.0.1 as we are debugging through the locally installed tomcat server.
o Port à 8000 ( It should match the port specified in the tomcat configuration as in step 1)

Fourth, we need to change the Output Directory from “ViewController\classes” to “ViewController\public_html\WEB-INF\classes”

And to do this go to View Controller Project settings then to Project Content and change the Output Directory Textbox.

4 comments:

Steve said...

Hi,
This step does not make sense as described. Why do this step? What is the project1.xml for?

>>Second, go to the folder where tomcat is installed (for me it is “C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\Catalina\localhost”) and create a file called “project1.xml” for example, and paste this line in it.

project1\ViewController\public_html" path="/project1" reloadable="true" />

Where

docBase is the path to your public_html folder

Shereef Sakr said...

Hi Steve

This step allows tomcat to see jsp's and class files in the jdev Project path. If you didn't do this step you will have to redeploy the web application every time you make a change.

Evaldas said...

shereef sakr,

I think Steve is a bit confused because the line to paste is not complete:

project1\ViewController\public_html" path="/project1" reloadable="true" />

should be something like this:
<Context path="/project1" docBase="PATH_TO_APP\public_html" debug="0" reloadable="true">
<!-- <Logger ... /> (good thing to have) -->
</Context>

or you can also paste this line to {tomcat_home}/conf/server.xml under <Host> element (As far as I remember this is the way to do it in Tomcat v6).

Anna said...

Great and Useful Article.

Online Java Training | Java Training in Chennai | Java Training Institutes in Chennai | Online Java Course