Project

General

Profile

Debugging the Converted Application in Docker

Introduction

This section shows how to open the FWD server in debug mode inside the Docker container, attach that process to the IDE, and open the Debug view for further debugging.

Start the server

This should be executed from a Docker bash shell opened under dbash.sh (described here).

In order to start the server, navigate to the project root and run the script that starts the server:

cd ~/projects/<project_name>/deploy/server
./server.sh -d

This sets the debugger to listen on port 2080. This value is needed in the next section.

Attach process - Eclipse IDE

Create a new configuration

A Remote Java Application configuration needs to be done in the IDE in order to connect to the server process.

1. Create a new Remote Java Application Debug Configuration. In Eclipse, this is under Run > Debug Configurations.... Then, in the opened window, on the left side, select Remote Java Application, and select New launch configuration from the top left side.

2. A new configuration should appear on screen:
  • The Name field can be changed to match the application name.
  • Under Project, click on Browse... and select the FWD project.
  • Under Connection Properties, configure the Host to match the needs (e.g. localhost), and the Port to 2080, which is the value shown when the server started in debug mode.
  • Under the Source tab, click on Add..., then Java Project, and add the FWD project. This will allow source lookup while debugging for FWD code.
  • Under the Source tab, click on Add..., then File System Directory, and add the folder with the converted application's source code (like ~/projects/hotel_gui/src). This will allow source lookup while debugging, for the converted application.

Finally, click on Apply, and Debug, which will start the debugging process, as long as the server is already started in debug mode.

Use an existing configuration

If a Remote Java Application Debug Configuration is already created, that can be used to perform the debugging process. Once the server is started in debug mode, the debug application can be started via option a or b:

a. In the top bar, choose Run, then Debug History, then the Remote Java Application created.

b. Click the down arrow from the debug icon at the top, and select the Remote Java Application created.

Attach process - VS Code IDE

1. Inside the .vscode directory, a launch.json file needs to be created if it doesn't already exist. To achieve this, right-click on .vscode, select New File..., and call it launch.json. Take as a reference the following content:

{
    "configurations": [
        {
            "type": "java",
            "name": "Remote Debug",
            "request": "attach",
            "hostName": "localhost",
            "port": 2080
        }
    ]
}

This will tell the IDE to attach the process to the running server by connecting to localhost, port 2080. Feel free to adjust these values as needed.

2. To launch the Remote Java process, make sure the server is already started in debug mode. Then, select Run in the top bar of VS Code, and press Start Debugging.

Debug mode

Once the process starts, the perspective will be switched to Debug View. In here, there are various things that can be achieved:
  • Follow the chain of calls to a specific point in the application.
  • Have breakpoints in desired spots.
  • Analyze expressions on the go.

The debugger will show the converted application's Java code, for which the equivalent of the 4GL code resides in a cache file. The name of the Java class may not necessarily match exactly the name of the converted 4GL file, but it can be found in the javadoc for the Java class, in a comment like:

/**
 * Business logic (converted to Java from the 4GL source code
 * in start.p).
 */

To find the .cache file, search the cvt/ folder for the i.e. start.p.cache file.

In Eclipse, the lookup of a Java type can be done via CTRL+SHIFT+T. Here, enter the Java name of some class; if the source code does not appear, then choose Attach source and select:
  • for FWD, choose Workspace location and select the <project>/src folder
  • for converted application, choose External location, then External folder and select the application's converted source code folder, like ~/projects/hotel_gui/src

Making changes in the IDE to converted Java code

For very large applications, IDEs do not necessarily handle 10k's of .java classes. At the least, you would not want to let the IDE compile the entire converted source code. This can be done with some manual steps:
  • add to the IDE a new source folder: this is the srcnew/java folder from the converted application
  • when you want to change a Java file to test some specific changes (like enhancing a certain converted file only in Java), copy it from the src/ folder to the srcnew/java folder (remember to use the same exact folder structure)
  • make any changes in the IDE
  • in the dbash container shell, stop the server:
    cd ~/projects/<app>/deploy/server
    ./stop_server.sh
    
  • in the dbash container shell, recompile the application:
    cd ~/projects/hotel_gui  # or other application
    ant compile jar deployapp.prepare
    
  • start again the FWD server - the changes are now applied