aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Debugging in java j2ee Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Debugging in java j2ee" Watch "Debugging in java j2ee" New topic
Author

Debugging in java j2ee

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
Possible ways for debugging java ,javascript, jsp and servlet . Can we use System.out.println debugging java.
Soumil Shah
Ranch Hand

Joined: Jul 13, 2009
Posts: 54
yes.. surely.. other ways could be alert message, log4j....
Anoop Krishnan
Ranch Hand

Joined: May 03, 2001
Posts: 163
Use of System.out.println debugging is very bad and time consuming, but you can do it in J2EE too.
What about using Eclipse as a debugger for Java (JSP & Servlet) and Firebug for javascript.

You can start your Application server in debug mode and let your eclipse connect to the debug port of your application server
set break points in your servlet and jsp and step through it.


I just want to know is there any body call my bean's Getter and Setter methods with "Please" in front - My favorite quip from Bugzilla
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
I have not used Eclipse IDE, should i set breakpoints for every line or how to do for entire servlet.
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
You can start your Application server in debug mode and let your eclipse connect to the debug port of your application server
set break points in your servlet and jsp and step through it.


Where can I find tutorials about doing this in Eclipse? I would like to not use System.out.println() to do J2EE debugging.
Anoop Krishnan
Ranch Hand

Joined: May 03, 2001
Posts: 163
For me Programming Java with out Eclipse is like living with out Oxygen
But you have to begin in One day now it is the time to switch to Eclipse

Just google for it and you will get what you want.
I can give you a small description.


For J2EE application you must use remote debugging with Eclipse where eclipse will listen to a port of your application server which is dedicated for debugging.

In Eclipse (Use the latest one which is Galileo)
Create a J2EE project in the eclipse workspace

Menu -> Run -> Debug Configurations which will Open a Dialog
The double click Remote Java Application
Then you get a New Configuration dialog
Give a name for your current configuration so that you can easily find it later
In the Connect tab set the following properties
Project -> Set it to your J2EE project in your Eclipse workspace
Connection type -> Standard (Socket Attach)
Connection Properties -> Host = your j2EE application server host
Connection Properties -> Port = Debug port of your j2EE application server host

Click apply button to save you configuration


Now start your application server in debug mode
If you use tomcat you can start tomcat in debug mode as
[CATALINA_HOME]/bin/catalina.sh jpda start
and port 8000 is the default debug port of tomcat.

Now go to eclipse and open the same dialog and double click on already saved remote debugging configuration
or
Select the already saved remote debugging configuration and click the button debug

Now go to the servlet which you want to debug and put a break point where you think the problem is

Now open the browser and link to your servlet with the url

Then you can see that when the servlet execution in the application server reaches to the line where you put the break point the your browser query will hang and Eclipse will jump to a debug configuration which will highlight the line where you set the break point.
Now you can press F6 to step from one line to tho the next and F5 if you want to step in to your method calls in each line. Now you are executing your servlet in the application server step by step

The debug mode of Eclipse has a variable pane which list current state of all variables and objects of your class which is debugged now.
In the Expressions pane you can add your watch expression codes only for debugging purpose


I know it is not very easy when you do it first time but once you do this you will just love it.

If you have any question you can ask me . It will be good if you come with very specific issue and some code snippet .
I think that will help everybody in the forum to help you better and quicker.



 
jQuery in Action, 2nd edition
 
subject: Debugging in java j2ee