Copy link to clipboard
Copied
We just installed CF 2021 Enteprise on our Dev server (Win Server 2019) last week.
<cfquery name="qUserGroups" dbtype="query">
SELECT groupName FROM request.store.groups
WHERE groupID IN (#qUsers.userGroupList#)
</cfquery>
Whenever a Query of Query gets a shared scope variable, this error occurs:
"Error casting an object of type class coldfusion.runtime.RequestScope cannot be cast to class coldfusion.runtime.Struct (coldfusion.runtime.RequestScope and coldfusion.runtime.Struct are in unnamed module of loader coldfusion.bootstrap.BootstrapClassLoader @69909c14) to an incompatible type. This usually indicates a programming error in Java, although it could also mean you have tried to use a foreign object in a different way than it was designed."
I have also tried setting the value to a local variable or even the application scope, but the error is the same. Help!
Copy link to clipboard
Copied
The Request scope is meant to be used in this way: request.variableName. The problem you're facing is that you are using the shared scope, Request, as if it is a custom struct. That is, request.key1.key2.
That might work on certain occasions, as ColdFusion is weakly typed, but could fail in others. When ColdFusion evaluates request.key1.key2, it assumes Request is a struct or attempts to cast it into a struct. The result is a casting error.
To correct this, simply rename the query to request.store_groups.