StructClear and the Client Scope

The other day I was building a quick demo of an application which used client variables for session management. On logout I was just doing StructClear(client) to clear the client scope. It has been awhile since I have worked on login code for a application which uses client variables for session management, but this is an approach you see used quite often for clearing variables in the session scope on logout.

Well, after logging out using this method I started to see the following error in the ColdFusion logs:

java.lang.NullPointerException
at coldfusion.runtime.Cast._double(Cast.java:531)
at coldfusion.runtime.Cast._int(Cast.java:343)
at coldfusion.runtime.ClientScope.UpdateGlobals(ClientScope.java:127)
at coldfusion.runtime.ClientScopeServiceImpl.PersistClientVariablesForRequest(ClientScopeServiceImpl.java:267)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:33)
...

Some quick googling led me to comments in the ColdFusion Livedocs which in turn pointed me in the right direction. StructClear was actually deleting the "read-only" Client variables (CFID, CFToken, URLToken, HitCount, TimeCreated, and LastVisit) and this was causing the error. According to the Livedoc comments it is really only the HitCount variable which causes the issue, but the ColdFusion documentation does say:

ColdFusion lets you delete or change the values of the built-in client variables. As a general rule, avoid doing so.

Given this I updated my logout code to use the ColdFusion ClientVariable functions and all was well:

<cfloop list="#GetClientVariablesList()#" index="var">
<cfset DeleteClientVariable(var) />
</cfloop>

I'm pretty sure I knew this at one point, but like I said it has been so long since I've done anything like this with the client scope I had totally forgotten about those ClientVariable functions.

Starting CF Instances via the JMC

If you are running multiple instances of ColdFusion you may manage those instances via the JRun Management Console (JMC). If you are on Windows and you installed a Windows service for each of your instances it is important to note that starting those instances via the JMC does not start the associated Windows service. Instead it launches the JRun instance as an application running under the same user the JRun admin instance (the "Macromedia JRun Admin Server" service) is running under.

Why might you care? Well, by default the JRun services run under the local system account. If you have modified your CF instances to run under another account via the Service Manager but left the JRun admin instance as is, you may run into issues when you launch your CF instances via the JMC. At this point they will be running under the the local system account, or whatever account you have your admin instance configured to run under, and that account may not have the permissions your instance needs.

What to do? One option is to always start the services using the Windows Service Manager. If your instances use different accounts this may be the only option short of launching JRun via the command line. If all of your instances run under the same account you may also be able run your admin instance under that same account. Instances launched via the JMC would then have the correct permissions even though the associated Windows service may not be started.

This was all observed in CFMX 6.1. I'd be interested to know if the same applies to the Enterprise Manager built into the CFMX 7 administrator.

Google to Add Presentations

A while ago I posted about a couple of Java libraries for working with Powerpoint presentations. Looks like Google has acquired one of the companies I mentioned, Tonic Systems, and will be adding presentations to their Docs & Spreadsheets offerings. I think Google has done a great job with their Docs & Spreadsheets. Given the power of the Tonic software I have no doubt Google will come up with another awesome application.

Object Search in SQL Query Analyzer

In MS SQL Query Analyzer for SQL 2000 you can search for just about any database object using the Object Search. To access Object Search just press the F4 key while in Query Analyzer. Since my co-worker turned me on to this feature I've found myself using it quite a bit. It is great for finding column and table names in large databases as it allows you to do wildcard searches. Say for example you can't remember if a column is named "LastLogIn" or "LastLoggedIn" and say you also can't remember which table it is stored in. Object Search to the rescue. Just select the "Column" object type and search for "LastLog%" and you will get a list of all columns that start with LastLog, as well as what tables they are stored in.

[More]

Daylight Saving Time Revisited

I've posted about DST issues in the past, but we recently had an issue at work so I thought I'd share my findings again. According to the Adobe Technote "Working with daylight savings [sic] time in ColdFusion MX":

The current time is calculated correctly in Macromedia ColdFusion MX and higher, regardless of whether the Automatically Adjust Clock for Daylight Saving Changes option is enabled or disabled in the computer's Control panel Date/Time Properties. In previous versions of ColdFusion, the current time would be offset by one hour when this option was disabled.

[More]

I'm Naked Too!

I've decided to join Andy Jarrett and participate in CSS Naked Day. I feel kind of naughty getting naked at work, but it only took about two minutes using the function Rahul Narula posted on Andy's blog.

Show your support for web standards by showing off your <body>!

LogWatcher Plugin for Eclipse

Lately I've been using the tail utility available in the Windows Server 2003 Resource Kit Tools to monitor ColdFusion log files -- that is until today.

I usually don't repost things I read on the Goog, but earlier today Steve Brownlee posted about the LogWatcher plugin for Eclipse. I just installed this plugin and I can already see it will be an extremely useful tool. If you use Eclipse definitely check it out.

BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.