Fork me on GitHub Fork me on GitHub

Debugger


Introduction

Jaggery debugging feature is enabled by the means of Rhino JavaScript Debugger. Eclipse IDE has plugin support for Remote Javascript debugging with Rhino. Support is given for both client and server side thus, we can setup Rhino debugging in our own server and we can connect to a server already running the Rhino debugger. Jaggery server is embedded with an embedded Rhino Debugger and we can connect to it via Eclipse IDE. Currently this feature is only compatible with Eclipse Java EE IDE for Web Developers: Juno Release.

Configuring the debugger

Both the client and server sides need to be configured before you can start the debugger.

Server side

  1. Navigate to plugins directory of your Eclipse installation and locate following jars.
    • org.eclipse.wst.jsdt.debug.transport-1.0.100.v201109150330.jar
    • org.eclipse.wst.jsdt.debug.rhino.debugger-1.0.300.v201109150503.jar
  2. Extract jaggery-0.9.0-SNAPSHOT.zip to a directory you prefer. Let's call it JAGGERY_HOME
  3. Copy the above mentioned jars into JAGGERY_HOME/carbon/repository/components/dropins directory.

Client side

  1. Import the project which contains the script you need to debug into your current Eclipse workspace.
  2. Set the JavaScript editor as the default editor for .jag files
    1. In Eclipse go to Windows > Preferences
    2. Open General > Content Types preference dialog.
    3. Under Content types select Text > JavaScript Source File. It will contain only .js under File associations. Add a new File association as .jag.




  3. Create a new Remote Javascript launch configuration. In order to do so,
    1. Open Debug Configurations dialog and double-click Remote Javascript launch configuration to create a new one and fill required fields
    2. Mozilla Rhino - Attaching Connector should be selected as the connector.
    3. Fill in the hostname and the port number of the host where the debugger is running.




    4. Switch to the Source tab, remove the Default project and add the project which you want to debug.




  4. Set breakpoints as required and change settings to Suspend For All Script Loads(optional).

Starting the debugger

  1. Navigate to JAGGERY_HOME/bin .
  2. Run sh ./server.sh -DjsDebug=<port> command to start the server in debug mode.
  3. Point the browser url to http://localhost:9763/apps/<project_name>/<file_name>.jag .Page will wait without loading until the debugger client is connected.
  4. Go to the Eclipse IDE and launch the newly created debug configuration.




IMPORTANT:As we don't have editor support for Jaggery yet, debugging can be used on scripts which have only JavaScript content. Also as the JavaScript editor doesn't allow <% and %> characters they need to be commented out. We are working on improving the debugger.