See Chapter 4, Debugging Applications, in Sun GlassFish Enterprise Server v3 Application Development Guide.