Inconsistency between Railo and CF 8...Railo Wins.

{ Posted By : Eric Cobb on February 16, 2009 }
2200 Views
Related Categories: Railo, ColdFusion

I found an interesting inconsistency today between Railo and CF 8, and I have no idea what the real problem is or how to fix it.

I used the Illudium PU-36 Code Generator to create the CF components for a project that I'm working on. The problem I'm having is, whenever I make a call to one of my service components I get a "coldfusion.sql.QueryTable cannot be cast to java.util.Map" error on CF 8, but the same code works fine on Railo.

There's nothing fancy in my code, it's a pretty basic setup. I have a Bean, DAO, Gateway, and Service CFC for my Users table. I'm calling the getUser method inside of my Service CFC. The getUser method calls the createUser method, which just runs through the getters and setters. Here's the actual code that I'm talking about.

<cffunction name="createUser" access="public" output="false" returntype="User">
<cfargument name="ID" type="Numeric" required="true" />
<cfargument name="fName" type="String" required="false" />
<cfargument name="lName" type="String" required="false" />
<cfargument name="Email" type="String" required="false" />
<cfargument name="Usr" type="String" required="false" />
<cfargument name="Pwd" type="String" required="false" />
<cfset var User = createObject("component","User").init(argumentCollection=ARGUMENTS) />
<cfreturn User />
</cffunction>
<cffunction name="getUser" access="public" output="false" returntype="User">
<cfargument name="ID" type="Numeric" required="true" />
<cfset var User = createUser(argumentCollection=ARGUMENTS) />
<cfset VARIABLES.UserDAO.read(User) />
<cfreturn User />
</cffunction>

The illudium code is unaltered, and everything works fine when I run this on Railo. But every time I run it on CF, I get "coldfusion.sql.QueryTable cannot be cast to java.util.Map". And it's not just for this CFC, it's happening in several of my Service components. I thought it might have something to do with my var being named the same thing as the CFC I'm creating an object to in the createUser() method, but I changed that and it still threw an error.

Oh, well, it works on Railo and that's what I'm using, so all is good. :) I was just wondering if anyone else has ever run across this error. I would really like to know that my app worked on both Railo and CF. I've googled the error, but come up with nothing. By the way, this is my first attempt at an app using the MVC pattern (or anything even remotely OO), so if I'm not making any sense here, sorry. I'm learning as I go.

Comments
Andrea's Gravatar Check database drivers.
Probably issue is there.
# Posted By Andrea | 2/17/09 4:04 AM
Tony Garcia's Gravatar Yeah, check what Andrea said. I don't think it's a CF issue becuase I've used Illudium-generated code similar to yours and it works fine for me on both CF8 and Railo.
# Posted By Tony Garcia | 2/17/09 10:31 AM
Eric Cobb's Gravatar Well, it looks like I finally found out what the problem was. It wasn't the database drivers because the other components seemed to be running queries with no problems (thanks for the suggestions, though!).
As it turns out, it was the way I was calling the Service CFC that was causing the problem. I was actually passing a query object as the argument collection to the getUser method of the Service CFC. Railo didn't seem to have a problem parsing through it as a struct, but CF didn't seem to like it.
Here's an example of what I'm talking about:

<cfquery name="UserInfo">
SELECT fName, lName, Email
FROM   users
WHERE   ID = 12345
</cfquery>
<cfset ServiceCFC.getUser(argumentCollection=UserInfo) />

The above (pseudo) code works in Railo. It will take the query as an argument collection with no problems. However, CF 8 won't. The below code is what I had to do to get it to work with CF.

<cfquery name="UserInfo">
SELECT fName, lName, Email
FROM   users
WHERE   ID = 12345
</cfquery>
<cfset ParamStruct = StructNew() />
<cfloop list="#UserInfo.columnlist#" index="i">
<cfset ParamStruct[i] = UserInfo["#i#"] />
</cfloop>
<cfset ServiceCFC.getUser(argumentCollection=ParamStruct) />

I guess in the end, it was the way that I was calling the CFC that was causing the problem. But it's still strange that Railo was able to process it while CF couldn't.
# Posted By Eric Cobb | 2/17/09 11:08 PM
Mark's Gravatar I'm just wondering how you got it to work with Railo?
# Posted By Mark | 12/7/09 11:32 PM