User Guide
286 Developing Web Applications with ColdFusion
Approaches to Debugging Java CFXs
Java CFXs are not standalone applications that run in their own process like typical
Java applications. Rather, they are created and invoked from an existing process —
ColdFusion Server. This makes debugging Java CFXs more difficult because it is not
possible to use an interactive debugger to debug Java classes that have been loaded by
another process.
To overcome this limitation, you can use one of two techniques:
• Debug the CFX while it is running within ColdFusion Server by outputting
debug information as needed. See “Outputting Debug Information” on page
286 for details.
• Debug the request in an interactive debugger offline from ColdFusion Server
using the special
com.allaire.cfx debugging classes. See “Using the
Debugging Classes” on page 286 for more information.
Outputting Debug Information
Before using interactive debuggers became the norm, programmers typically
debugged their programs by inserting output statements in their programs to indicate
information such as variable values and control paths taken. Often, when a new
platform emerges, this technique comes back into vogue while programmers wait for
more sophisticated debugging technology to be brought to the platform.
If you need to debug a Java CFX while running against a live production server, this is
the technique you must use. In addition to simply outputting debug text using the
Response.write method, you can also use the DEBUG attribute in your Java CFX. This
attribute flags the CFX that the request is running in debug mode and therefore should
output additional extended debug information. For example, to call the
HelloColdFusion CFX in debug mode, you would use the following CFML code:
<CFX_HelloColdFusion" NAME="Robert" DEBUG="On">
To determine if a CFX has been invoked with the DEBUG attribute, you use the
Request.debug method. To write debug output which will be printed in a special
debug block after the tag finishes executing, you use the
Response.writeDebug
method. See the “Java CFX Reference” on page 311 for details on using these methods.
Using the Debugging Classes
To develop and debug Java CFXs in isolation from the ColdFusion Server, you use three
special debugging classes that are included in the
com.allaire.cfx package. These
classes enable you to simulate a call to the
processRequest method of your CFX within
the context of the interactive debugger of a Java development environment. The three
debugging classes are:
•
DebugRequest — An implementation of the Request interface that enables you
to initialize the request with custom attributes, settings, and a query.