Skip to main content
Hedge
Inspiring
December 28, 2014
Question

CF11 cfc gives 500 error but cfm is fine

  • December 28, 2014
  • 2 replies
  • 6593 views

We are testing our cf code which all works fine on a CF9 Windows Server 2008 machine but we are going to migrate to a CF11 Windows 2012 R2 machine. We have a test machine setup and all the code moved over and so far the cfm pages seem to work fine as well as the Application.cfc page but when we call a cfc via AJAX or we visit the cfc methods directly we get a 500.0 error Application could not be found.

Anybody else run into this?

This topic has been closed for replies.

2 replies

Legend
December 30, 2014

I would research how to turn on detailed error reporting, even if it's only temporary. This will better pinpoint the error. IIS by default intercepts all errors, suppresses any details, and spits out an error 500. Another problem I have seen to cause 500 errors is having an error trap the throws a secondary error. To eliminate this possibility I comment out all CFERROR tags and onError application functions.

Anit_Kumar
Community Manager
Community Manager
December 30, 2014

To turn on detailed error reporting,


Uncheck the “Enable HTTP status codes” under Settings inside CF Admin. This will give you CF related error.


Regards,

Anit Kumar

Hedge
HedgeAuthor
Inspiring
December 28, 2014

I am beginning to suspect something changed in how Application.cfc works with sub directories in CF 11. I can take the .cfc I am trying to access out of the sub directory (which has it's own Application.cfc) and put it in the root directory (which has it's own Application.cfc) and it works fine. Any ideas as to why this might be?

Carl Von Stetten
Legend
December 29, 2014

Does one or the other Application.cfc have an onCFCRequest() method in it?  If they both do, is the code inside the method the same?

-Carl V.

Charlie Arehart
Community Expert
Community Expert
April 14, 2018

I found the root cause: CF11 added a servlet mapping for /api that's interfering with your request:

ColdFusion 11 Sometimes Chokes on /api • FusionGrokker

You can comment it out in web.xml, or change your folder name to something other than /api.


Adding a bit more about this solution to the problem, first about Adam's last post, the URL he offered no longer works, but here is the page from the web archive:

 

http://web.archive.org/web/20150925003635/http://fusiongrokker.com/post/coldfusion-11-sometimes-chokes-on-api

 

Second, in case it may help others to find this (since his old post no longer shows up in search engines), you can also tell this is happening because you may see an error in your CF application.log (and coldfusion-out.log) about "Application  could not be found", if your request is for a folder called /api  which you have but (as of CF11) CF is looking instead for a REST service registered in the CF Admin or application.cfc and is finding none. Of if you have a subfolder like /api/whatever/ the error might say "application whatever could not be found").

 

And as Adam's post noted, you could also find more detail on the problem (and the reference to CF's restservlet) in the CF's exception.log.

 

He proposes one solution is to rename your web site's /api folder to another name (which he acknowledges can have problems), or he shows editing CF's web.xml and comment out its reference to /api if you don't use CF's rest feature.  I'll add a clarification that there are multiple web.xml files in CF: he meant the one in cfusion/wwwroot/WEB-INF/web.xml (of change cfusion to instancename if using CF's multiple instances feature). And I'll add a recommendation that you backup that file before touching it, in case you make a mistake and need to quickly recover.

 

Finally, as an update, note that CF2018 did change that internal path to instead be /restapps, so folks using /api for  web site folder names would no longer hit this problem. It's only those on CF11 and 2016.

/Charlie (troubleshooter, carehart. org)