• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Debugging in java j2ee

 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Possible ways for debugging java ,javascript, jsp and servlet . Can we use System.out.println debugging java.
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes.. surely.. other ways could be alert message, log4j....
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not used Eclipse IDE, should i set breakpoints for every line or how to do for entire servlet.
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic