Skip to main content
Participating Frequently
February 22, 2017
Answered

Coldfusion 2016 - Error invoking CFC

  • February 22, 2017
  • 3 replies
  • 2694 views

Hello,

We're upgrading from CF8 to CF2016, and as with all big revisions leaps there are certain pain points. My current one is accessing any of our CFCs. Of course they fine work in CF8, but dropped into CF2016 suddenly they can not be found even though they are in the same folder as the web app that is calling them.

Here's what I have debugged so far for one web app:

1. Yes, the functions in the CFC work. I tested them with CFINVOKE.

2. I've played with various paths, from the root to the specific folder. (ie cfc:webroot.next.next.etc.autosuggest)

3. I've also moved the CFC around but no success.

We're using Windows 2012.

Here's the current set up (yes, I know CF is moving away from the autoSuggest with CFINPUT, but work with me, I'm upgrading not updating.)

<cfinput onFocus="textHighlight('textedit')" type="text" name="Clinical_Rep_Auto" size="50" maxlength="50" value="" autosuggest="cfc:autosuggest.findClinicalNameWithNetID({cfautosuggestvalue})" autosuggestminlength="2" maxresultsdisplayed="20" />

I know CFCs require full mapping, and I believe I've done that simply because it only errors out when typing in the textbox, then suddenly it doesn't know where the CFC is.

Anybody else run into this with CF2016?

Thanks,

Ty

This topic has been closed for replies.
Correct answer BKBK

Odd. We are assuming of course that the form page (index.cfm) and the CFC (autosuggest.cfc) are in the same directory. Then, as Haxtbh says, this behaviour also suggests a mapping. Is there a mapping to the CFC in the ColdFusion Administrator?

In any case, there is a workaround. Create the following mapping in the ColdFusion Administrator:

Logical Path: /proctorEvaluation

Directory Path: D:\webRoot\inweb\app\ProctorEvaluation

Then modify your code to:

<cfinput onFocus="textHighlight('textedit')" type="text" name="Clinical_Rep_Auto" size="50" maxlength="50" value="" autosuggest="cfc:proctorEvaluation.autosuggest.findClinicalNameWithNetID({cfautosuggestvalue})" autosuggestminlength="2" maxresultsdisplayed="20" />

This workaround has the advantage of leaving the rest of your code intact.

3 replies

BKBK
Community Expert
Community Expert
February 23, 2017

@tys62838125, it is unlikely that this is caused just by your move to ColdFusion 2016. I tested your code in ColdFusion 2016, placing the following 2 files in the same directory:

testPage.cfm

<cfform>

     <cfinput name="cfautosuggestvalue">

     <cfinput onFocus="textHighlight('textedit')" type="text" name="Clinical_Rep_Auto" size="50" maxlength="50" value="" autosuggest="cfc:autosuggest.findClinicalNameWithNetID({cfautosuggestvalue})" autosuggestminlength="2" maxresultsdisplayed="20" />

</cfform>

autosuggest.cfc

<cfcomponent>

<cffunction name="findClinicalNameWithNetID" access="remote"  returntype="array">

    <cfargument name="suggestedValue" required="true" type="string">

    <cfset var item = arrayNew(1)>

    <cfset item[1]="aspirin">   

    <cfreturn item>

</cffunction>

</cfcomponent>

When I open the CFM page in the browser and enter the letters a and s, it works as expected.

The moral: make sure the path to your form page is

/app/ProctorEvaluation/yourFormPage.cfm

The error message suggests that it is currently

/webRoot/inweb/app/ProctorEvaluation/yourFormPage.cfm

Participating Frequently
February 23, 2017

In IIS we have set the physical path of the site in question as "D:\webRoot\inweb," so yes those folders exist on the file server. By doing so the URL for our web apps can be listed as this:

"http://OurDomainHere.com/app/ProctorEvaluation/index.cfm"

instead of

http://OurDomainHere.com/webRoot/inweb/app/ProctorEvaluation/index.cfm

That's the same setup we had before. And to test the theory I changed the physical path to simply "D:" and, of course the CFC functions properly.

As I understand it, though, when the CFINPUT fires autosuggest it generates a javascript string as listed earlier in this thread and sends it to the browser, which runs and returns the results to the textbox. It's in the firing that "webRoot/inweb" is being added to the URL string. This doesn't happen on the older server and CF version. All paths are set up the same, etc. As Dave mentioned early regarding CFINPUT it uses an old library and perhaps it no longer functions the same way in CF2016. Just a thought. Either way, I'm not sure what the mechanics are of the firing portion of the javascript to understand how to work around it with our current IIS set up. I've been advised to simply pull the feature from the impacted web apps.

BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
February 26, 2017

Odd. We are assuming of course that the form page (index.cfm) and the CFC (autosuggest.cfc) are in the same directory. Then, as Haxtbh says, this behaviour also suggests a mapping. Is there a mapping to the CFC in the ColdFusion Administrator?

In any case, there is a workaround. Create the following mapping in the ColdFusion Administrator:

Logical Path: /proctorEvaluation

Directory Path: D:\webRoot\inweb\app\ProctorEvaluation

Then modify your code to:

<cfinput onFocus="textHighlight('textedit')" type="text" name="Clinical_Rep_Auto" size="50" maxlength="50" value="" autosuggest="cfc:proctorEvaluation.autosuggest.findClinicalNameWithNetID({cfautosuggestvalue})" autosuggestminlength="2" maxresultsdisplayed="20" />

This workaround has the advantage of leaving the rest of your code intact.

Dave Ferguson
Participating Frequently
February 22, 2017

One of the parts of upgrading is also updating older code to work with newer standards and tech.  What you are doing with cfinput can be easily replicated using jquery and ajax.  I advise anyone using cfinput and the other cfform family of tags to look for alternatives.  The cfform tags add a ton of unnecessary bloat and confusion as well as their js libraries are not current nor can you update them.

To your actual question.  Can you please let us know what the actual error you are receiving is?  It is hard to assist without knowing that critical part.

Inspiring
February 22, 2017

What is the exact error?

Participating Frequently
February 22, 2017

The error is "Error invoking CFC," which displays in a popup message once you start typing in the textbox. The rest of the message states that the CFC can not be found. As mentioned, CF initially knows when the page loads that it's there because if the CFC is moved to another location or I map it differently the page loads with an error that states the CFC can not be found, be sure to map it, etc.

I agree with you, Dave, but the mandate from above at the moment dictates otherwise. They would rather pull the feature than have me spend time rewriting code.

I suspect this issue started with an earlier version of CF, not specifically with CF2016.

Dave Ferguson
Participating Frequently
February 22, 2017

Check the browser developer console for an error.  I suspect there will be something there.