User Guide

384 Chapter 20 Using cfobject to Invoke Component Objects
Note that after you call GetException, the exception object is just like any other Java
component object, and you can call any methods on it.
The class loading mechanism
In ColdFusion prior to version 5, Java classes were loaded on demand and they were
not unloaded until the server restarted. This is the way a typical Java application
works and is appropriate for production systems. However, if you change a Java
method implementation, you must shut down the server and restart it before
ColdFusion can use the new class implementation.
In version 5, ColdFusion Server uses a custom class loader to load Java classes on the
fly, similar to Java Servlet engines. This enables you to modify Java method
implementations and use the new code from ColdFusion without restarting the
server.
ColdFusion 5 introduces the concept of dynamic load path, a directory that you can
specify on Cold Fusion Administrator JVM and Java Settings page. You deposit your
Java class files in this directory when you update the class implementation.
ColdFusion checks the class file time stamp when an object of the class is created. If
ColdFusion detects a new class file, it loads the class from that directory.
To use this feature, make sure that the Java implementation classes that you modify
are not in the general JVM class path. In addition, do not package the classes into jar
files or zip files. In all other ways, ColdFusion Class loader follows Java conventions
including those for package names and directory name mapping.
Suppose the directory C:\classes is the designated hot dynamic class path and
you have a class com.Allaire.Employee. You put the Employee.class file in the
following location:
C:\ classes\com\Allaire\Employee.class
The dynamic class-loading feature is meant for development uses, and incurs a
slight performance penalty associated with checking time stamps during disk IO
operations. For that reason, you do not use this feature in a production environment
where there might be high volume of traffic.
<cfcatch type="Any">
Catch any exceptions and handle them in
this block.
<cfset
exception=GetException(Obj)>
<cfset
message=exception.GetERrorMessage(
)>
Get the exception data by calling the CFML
GetException function and passing it the
Obj object. Set the message variable to the
string returned by the exception objects
GetErrorMessage method.
<cfoutput>
<br>The exception message is:
#message#<br>
</cfoutput>
Output the message string.
Code Description