If you're getting an
Error casting an object of type to an incompatible type
message while when using CFMX's urlDecode() function, this is because
you're using the wrong charset.
I was getting this error trying to parse some data coming from an XHTML document. Turns out the urlDecode() uses the charset of the URL scope as the default charset to use when decoding a string. Since the charset of the text in my XML document was different than that of my URL scope, I was getting the error. The message isn't very descriptive to the problem, so I spent time trying to cast the string using javaCast() function.
See the urlDecode() documentation for more information.