 |
Debug application code deployed on GlassFish using NetBeans ?
Posted by arungupta on June 18, 2007 at 07:31 AM | Comments (2)
 |
One of my friends asked how to debug a Servlet deployed on
Java Application
Platform SDK Update2.
Debugging Servlet is no different than debugging any application on the
Application Server. However
searching on java.sun.com gave really old results. Top-level Search
functionality is missing on glassfish.dev.java.net which
hopefully will be fixed soon. Googling finally showed
Debugging
Applications but this is again command-line. So I decided to write a short
blog describing the simple steps involved to debug a server-side application using
NetBeans/GlassFish. Application Platform SDK Update2 contains Sun Java System
Application Server 9.1 Beta2 which is equivalent to
GlassFish V2
b41d. |
- After you've installed GlassFish as '
Runtime' Server, then you need to
start the Application Server in debug mode by right-clicking on the Server
instance and selecting 'Start in Debug Mode'.
- This starts the Application Server on debug port 9009 and you'll see
something similar in your NetBeans IDE:

- The default web page when you browse your Web project is '
index.jsp'.
However if you need to debug your own Servlet then you need to configure it
as the default page by right-clicking on Project, selecting Properties, Run
category and specify the relative URL of the Servlet as shown below ('/NewServlet'
in this case):

- That's all it takes to configure GlassFish in debug mode using NetBeans
IDE. Deploy your applications on GlassFish or Application Platform SDK and
set up break points any where ever you like in your application code. To debug your Web project,
the simplest way is
to right-select your project and choose '
Debug Project' as
shown below:

If you
created a default Servlet using NetBeans IDE, then you can set up breakpoint
in 'processRequest' method and watch the debug output in 'Debugger
Console', 'Local Variables', 'Call Stack' and much more.
Check
NetBeans Debugging Applications for more information.
Technorati:
debugging netbeans
glassfish
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Even easier:
a Web/EAR project popup menu "debug" (or toolbar debug) does that automatically for you.
One single menu item to stop the server if it is not in debug mode, start it in debug more, attached to it with whatever correct port number is defined in domain.xml, then display the first page of the application:)
Posted by: ludo on June 18, 2007 at 08:34 AM
-
BTW, same for the profiler: if the NB profiler modules are installed, just use the "Profile" popup menu on a Web app or EAR app, magically glassfish will be configured in profile mode, and the IDE will attach to it and start a profiler session.
Posted by: ludo on June 18, 2007 at 08:37 AM
|