Skip to main content

Debugging SJS AS 7

Posted by gsporar on June 5, 2006 at 12:11 PM PDT

Version 5.0 of the NetBeans IDE has great support for version 8 of the
Sun Java System Application Server (SJS AS). But what if you are using version 7
of SJS AS? The IDE can still do plenty for you, including debugging. For the
test shown below, I used the 2004Q2UR4 release of SJS AS 7.1.

The first step is to start SJS AS in debug mode. This is easy enough to do. From
the admin console, go to the server settings page and check the Start in Debug Mode option.

debugF.png

Then just stop and restart the server. That will start the server's JVM with
the following flags (these are the default values):

  
    -Xdebug
    -Xrunjdwp:transport=dt_socket,
              server=y,
              suspend=n,
              address=2646
    -Xnoagent
    -Djava.compiler=NONE     
 

The second step is to create a project within the NetBeans IDE. This will give
the IDE a way to understand where your source code is, the required classpath, etc. For
this example I used one of the sample projects that is included with SJS AS 7.

  1. Choose File > New Project
  2. Under Categories choose General and then under
    Projects choose Java Project with Existing Ant Script and
    then click Next. Note:
    if you do not have an Ant build script then you can instead choose
    Java Project with Existing Source.
  3. Set the Location field to the folder that contains your project. Note
    that in the example shown below, the IDE found the build.xml that was
    in that folder.
  4. Set the Project Name to whatever value you want. Then click the
    Next button.
  5. Click the Next button again to advance past the Build
    and Run actions.
  6. Specify the source root folders for your application and then
    click Next.
  7. Specify the classpath for your application and then click
    Finish.

pN.png

The third step is to attach the IDE to the server's JVM. Choose Run
> Attach Debugger. In the Attach dialog verify that Socket
Attach is selected and that the Port number is 2646. Then click OK.

After the IDE attaches to the JVM you are ready to debug. You can set breakpoints by opening the source
files in the project and using Run > New Breakpoint.