Debugging a Web Application

Debugging a web application requires the use of remote debugging, in which the Uniface Debugger and the Uniface Web Application Server communicate with each other over a network. They can be running on the same machine or on different machines, and the network protocol can be TCP or TLS. Either one can be started first, but their configurations must match.

As partners in the debugging session, the Debugger and Uniface Server must have compatible configurations, so that one acts as the network server and the other as the network client, and they must use the same network protocol and port number on the host machine. For more information, see /deb and Debugging Remote and Server Processes.

You can use the pre-configured debugging environment provided by Uniface for debugging your web application.

Alternatively, you can configure your own remote debugging environment. For example, you may want to use TLS instead of TCP, or have a Uniface Web Server act as the network server instead of the Debugger.

Use Pre-Configured Server Debugger

The default Uniface installation on Windows provides a pre-configured remote debugging facility for web applications. It includes a Web Application Server called debug that can be used instead of the WASV normally used for running Uniface web applications.

To debug a web application using the default remote debugging environment:

  1. From the Uniface program group, choose Server Debug. This starts the Debugger as a TCP server, but it will not be visible until the debug Uniface Server runs a dynamic or static server page.
  2. Start a dynamic or static server page using debug instead of wrd in the URL:

    http://localhost:WebServerPort/uniface/debug/ServerPageName

    WebServerPort is the port number of the Uniface Tomcat web server, for example 8080.

    This causes Tomcat to invoke the server page via the Uniface Router, which starts a Uniface Server defined by the UST debug as a TCP client.

For example, assume that Server Debug starts the Debugger with TCP port 13002. If you enter the URL

http://localhost:8080/uniface/debug/MY_DSP

a Uniface Server is started with the extra switch: /deb=localhost+13002:wait.

Whether you first start the server page, or first start the Server Debug doesn’t matter; as soon as they are both running, the Debugger appears, with the execute trigger code of the server page.

You can now step through the code using the Debugger. For more information, see Uniface Debugger.

Use a Uniface Web Application Server as Network Server

The pre-configured environment defines the Debugger to be the network server and the Uniface Server process to be the network client, but you may prefer to have a Uniface Server function as the network server and the Debugger run as a network client for remote debugging.

In this case, closing the Uniface Debugger does not close the remote Uniface Server process. Once the connection is broken between the Uniface Debugger and the remote Uniface Server, it can be reestablished as long as the Uniface Server is running.

To configure this environment, you need to start the Uniface Server and Uniface Debugger with compatible debugger options using the /deb command line switch. For more information see /deb.

  1. On the web server machine, modify the Tomcat web.xml file, to define a servlet called mydebug and a servlet mapping that associates the <url-pattern> to the new servlet.

    Tip: Use the wrddbg servlet as a template.

    1. In your new servlet, define the MIDDLEWARE parameter to use the mydebug UST.
      For example:
      <init-param>
      <param-name>MIDDLEWARE</param-name>
      <param-value>UV8:localhost+13003|username|password|mydebug</param-value>
      </init-param>
    2. Define a <servlet-mapping>:
      <servlet-mapping>
      <servlet-name>mydebug</servlet-name>
      <url-pattern>/mydebug/*</url-pattern>
      </servlet-mapping>

    For more information, see web.xml.

  2. Restart Tomcat.
  3. On the server machine, modify the urouter.asn file, define a UST in the [SERVERS] section, to start a Uniface Server with the /deb command line switch, including the following arguments.

    /max=1 /deb=tcp:+Port:create

    where Port is the port number on which the Uniface Server will listen to the Debugger.

    Tip: Use the /max=1 flag in the UST so that only one server will be started and will receive all requests. Use the debug UST as a template.

    For example:

    mydebug=userver.exe /asn=my.asn /max=1 /deb=tcp:localhost+13010:create

  4. Restart the Uniface Router.
  5. On the machine where the Uniface Debugger runs, make a shortcut for the Uniface Debugger with the /deb command line switch, including the following arguments:

    udbg.exe /deb=tcp:HostID+Port:wait

    where HostID is the server host identifier (including the domain name if necessary) defined in step 2, and Port is the port number defined in step 2. For example:

    udbg.exe /deb=tcp:host1+13010:wait

  6. Start the Uniface Debugger.
  7. Start your web application using mydebug instead of wrd or debug in the URL of the server page. For example:

    http://host1:8080/uniface/mydebug/MY_DSP

    The Uniface Debugger is now connected to the server process over the TCP connection.

Related Topics