Wednesday, August 07, 2002

Enabling dynamic class reloading in CFMX

By default, CFMX will NOT dynamically reload changed servlets and CFOBJECT classes. This is a performance optimization. In a development environment, you may want to change that.

In the file [cfmx_home]\wwwroot\WEB-INF\jrun-web.xml, add the following line within the existing <jrun-web-app> element:

<reload>TRUE</reload>

Restart the server. CFMX will now reload classes from [cfmx_home]\wwwroot\WEB-INF\classes as well as classes in jar/zip archives in [cfmx_home]\wwwroot\WEB-INF\lib.

Note: The [cfmx_home]\wwwroot\WEB-INF\classes directory must contain class files only, not class archives. Java class archives belong under the [cfmx_home]\wwwroot\WEB-INF\lib directory

update:


I forgot to mention the true option as well. This will cause CF to automatically compile classes as well, when the class is requested. This is really a neat option since when compiling things yourself you need know how to get to the command line, run the java compiler, remember to provide the same classpath that CFMX would use when running the class, then remember to put the file in the correct directory. With this autocompile feature, CF not only does the compile for you but also uses its classpath and compiles it right where the source code exists. So for working with servlets, for instance, just put your servlet right in the WEB-INF/classes directory and call it, and CF will compile it for you if it's not already been compiled. And if it's been changed since last compiled and the reload and compile options are enabled, it will both compile and reload it. Nifty!

No comments: