Plugins (1059)


Training and Consulting (44)



EPIC Poll

What is your favourite developer portal?

[ Results | Polls ]

Votes: 541
Comments: 0

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
uri
Post subject: trying to debug tomcat with eclipse 3  PostPosted: Nov 28, 2004 - 11:03 AM
Guest





I am trying to debug code in tomcat.
My project is located in the file system and after compile i copy the classes files into the right place in tomcat (The code uses axis).

I am using the tomcat plugin for debugging.
I entered break points but the debugger doesnt stop in them.
Does anyone has an idea?

Thanks in advance
 
   
Reply with quote Back to top
Guest
Post subject:   PostPosted: Dec 29, 2004 - 02:06 PM






Eclipse Special: Remote Debugging Tomcat & JBoss Apps with Eclipse
By Bill Dudney

Over the last several weeks I've received a few questions about remote debugging with Eclipse. I posted about this on my other blog back in February here but with not enough info for others to follow.
If you go look at that blog entry you will see that I looked into 'in eclipse' debugging but did not find it satisfactory.
So without further ado here is how I use Tomcat, JBoss, and Eclipse to build and debug applications.
Whichever platform you are using (Tomcat or JBoss) you need to start them with the JPDA debugging enabled. For Tomcat this is very easy. In the $CATALINA_HOME/bin directory there is a script catalina.sh. If you provide the arguments 'jpda start' tomcat will startup and listen on port 8000 for a debugger connection.

With JBoss its only slightly more complicated. Basically you need to specify the JAVA_OPTS to have java start up listening for debugger connections. I typically copy the $JBOSS_HOME/bin/run.sh to $JBOSS_HOME/bin/run-debug.sh but you can just as easily setup the JAVA_OPTS environment variable and use the run.sh script.
The value of JAVA_OPTS needs have -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4142,suspend=n specified.
So this is what is going on with this argument list
• Xdebug == start the jvm and listen for debugging connections
• Xrunjdwp... == the info on how to connect to do remote debugging
• server=y == start in server mode (i.e. wait for connections, don't go out looking to connect
• transport=dt_socked == use sockets, this works (I think) only on unix (I'm on a mac), on Windows you have to use shared memory via the transport=dt_shmem argument instead. I'm fairly sure this works but its been a while since I tried it on Windows. YMMV. here(http://java.sun.com/j2se/1.4.2/docs/guide/jpda/conninv.html) is the official info on the connection arguments
• address=4142 == the port to connect to or the shared mem address to use
• suspend=n == don't wait for a debugger to tell you what to do, go ahead and launch
Once you have JBoss or Tomcat running and listening for debugging connections you are good to go for connecting with Eclipse
The first thing you need to do is create a 'debug launch configuration' by bringing up the launch configuration editor. Figure 1 shows the menu item to invoke to make that happen
When the launch config editor appears select 'Remote Java Application' from the 'Configurations:' selection list on the left hand side then click the 'New' button. Figure 2 shows the defaults that appear for me after hitting the 'New' button.
Since it defaults to the Tomcat port leave the port number set to 8000, if yours is different then change it to 8000. Notice also that you can specify the host to connect to. If you have access to the port and the process is running on another machine then you can debug the process remotely. This works out really well for those situations where it works fine in your local env but not in the test env. I usually rename the configuration (it defaults to the name of the project for me) to 'Debug Tomcat' or something like that.
The other options (Source & Common) can be ignored for now. If you have not already launched tomcat in debug mode do so now on the command line with $CATALINA_HOME/bin/catalina.sh jpda start. When its launched go back to the Eclipe launch configuration editor and hit the 'Debug' button. If you are not auto switched to the'Debug' perspective go there now. You should see a 'Debug View' that looks a lot like Figure 3.
Your code should be directly below the Debug View if you have the default layout still in place. If so go there and set a break point in one of your servlets' service methods (or any other code that is being executed in Tomcat, like a struts action or whatever) and then go to the Web browser and tickle the code that you have a break point set in. Notice that Eclipse suspends Tomcat at the breakpoint, comes to the front and lets you debug your program. Everything works just as if you were debugging locally.
Everything works the same within JBoss once you get it started with the debugging turned on. Keep in mind that you must set the port to match (in the above discussion of JAVA_OPTS it is set to 4142). So you need to create a new Debug launch configuration and specify 4142 as the port. Then you can debug your EJBs.


[NOTE] To make this works with Tomcat, you have to change the catalina.bat (or catalna.sh) like this:
set JPDA_TRANSPORT=dt_socket
rem set JPDA_TRANSPORT=dt_shmem
set JPDA_ADDRESS=8000
rem set JPDA_ADDRESS=jdbconn

Vincent.h
 
   
Reply with quote Back to top
Guest
Post subject:   PostPosted: May 20, 2005 - 03:49 PM






Exelent post. Works ok for me with Tomcat 5.5.9 and Java 1.5. Debugging of jetspeed 1.5 portlets, was a piece of cake.
Thanks
 
   
Reply with quote Back to top
Guest
Post subject:   PostPosted: Jul 05, 2005 - 01:42 AM






Hi I am also facing problem in debugging using Tomcat 5.7
I tried the procedure as suggested by Vincent but was unable to send a request using the post 8000.
Could any one help me out.
Thanks in advance.
 
   
Reply with quote Back to top
Guest
Post subject:   PostPosted: Sep 06, 2005 - 06:51 AM






NEAT!!

Quick and self explanatory
 
   
Reply with quote Back to top
Guest
Post subject:   PostPosted: Oct 27, 2005 - 09:51 AM






FYI, debuging with sockets works on any platform (including Windows). Smile
 
   
Reply with quote Back to top
Guest
Post subject:   PostPosted: Apr 10, 2006 - 08:38 PM






In-memory is apparently still not supported by Eclipse on Windows (3.2). Sockets works fine.
 
   
Reply with quote Back to top
Guest
Post subject:   PostPosted: Aug 07, 2006 - 08:43 AM






Hello,
I am trying to debug the application:
tomcat 3.3.2
eclipse 3.1.0
There is no "catalina.sh" in tihs version of tomcat. Can anyone please help me in setting this to the debug mode?
 
   
Reply with quote Back to top
gursesl
Post subject:   PostPosted: Feb 24, 2007 - 04:35 PM



Joined: Feb 24, 2007
Posts: 2
Location: Washington, DC
Vincent's post is great! You can also get more details at http://www.jacoozi.com/index.php?option=com_content&task=view&id=119&Itemid=134
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
gursesl
Post subject: Locate tomcat.bat  PostPosted: Feb 24, 2007 - 05:00 PM



Joined: Feb 24, 2007
Posts: 2
Location: Washington, DC
Anonymous wrote:
Hello,
I am trying to debug the application:
tomcat 3.3.2

For Tomcat 3.3.2 navigate to TOMCAT_HOME/bin and locate either tomcat.bat or tomcat. Make the necessary changes inside that file.

-----------------------------------
Levent Gurses
Jacoozi
New Generation E-Solutions for >> Thinking Companies
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits