Bug in calling CFC's remotely via the URL when using application.cfc

I've just been playing with the incredible <cfajaxproxy> tag in CF8 and have come across what appears to be a bug in Coldfusion when using application.cfc and calling CFC's via the URL method.

The URL method allows you to call CFC's via a URL and access any method in the CFC which has access="remote" set. Coldfusion will take care of returning the data as WDDX encoded or in JSON if using Coldfusion 8.


Anyway, I was testing this earlier today and found that no matter what I did, when calling a method in a CFC using the URL method a blank page was returned. It was incredibly frustrating!

A quick trip to the excellent #coldfusion IRC channel on Dalnet gave me the answer though (thanks Hapex) - application.cfc.

Well more specifically the onRequest method in application.cfc! For some reason if this method is defined in the file, remote CFC calls will simply display a blank page.

The solution? Comment out onRequest if you aren't making use of it. If you are, simply create an application.cfm and place it in the folder with your remotely accessed CFC's.

I believe this has been submitted to Adobe as a bug.. Hopefully it'll get fixed in the next release.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Sean Corfield's Gravatar The workaround I've been recommending is to add the following code to onRequestStart():

if ( right(arguments.targetPage,4) is ".cfc" ) {
structDelete(this,"onRequest");
structDelete(variables,"onRequest");
}

(This is actually what Fusebox 5.5 does)
# Posted By Sean Corfield | 2/1/08 11:55 AM
James Allen's Gravatar Aha, that's a lot more elegant. Thanks for posting Sean.

Hopefully this one will get fixed officially at some point. I believe it was also a problem in CF7.
# Posted By James Allen | 2/1/08 12:13 PM
Gerry's Gravatar Thanks! This page was the answer to my very frustrating morning as well.
# Posted By Gerry | 3/26/08 5:31 PM
James Allen's Gravatar No problem Gerry - glad it helped. One of those ultra annoying bugs as the cause is not immediately obvious and can lead to many hours of debugging perfectly working code.
# Posted By James Allen | 3/26/08 5:39 PM
Alex Sante's Gravatar You saved me what could have been hours of frustration. Thanks for posting this.
# Posted By Alex Sante | 3/19/09 9:54 PM
James Allen's Gravatar Hi Alex,
Brilliant! Glad I could help someone with this. I know when it got me there was many an angry comment shouted at the monitor.. ;) The last thing you need when trying to get remote CFC calls working.
# Posted By James Allen | 3/20/09 3:14 PM
Noe Rodriguez's Gravatar Thanks for the workaround!
# Posted By Noe Rodriguez | 4/2/09 6:13 PM
© 2010 James Allen | Contact Me
This blog runs on the awesome power of BlogCFC - created by Raymond Camden. This blog is running version 5.9.