Skip navigation
LyndonPatton
Currently Being Moderated

specified CFC could not be found

Nov 12, 2012 8:58 AM

Googled this for several hours, hope I'm missing the obvious as usual...

 

I'm using CF9 and IIS7. Followed/tailored simple autosuggest code from Ben Forta.

 

Came up with HTML:

 

[code]

<cfinput type="text" name="Employer" size="50" autosuggest="cfc:employer.lookupEmployer({cfautosuggestvalue})">

[/code]

 

and a CFC named employer.cfc in the current template folder:

 

[code]

<cfcomponent output="false">

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

          <cfargument name="search" type="any" required="false" default="">

          <cfset var data="">

          <cfset var result=ArrayNew(1)>

          <cfquery name="data" datasource="Binkley">

               Select lname

               From tdLicense

               Order By lname

          </cfquery>

          <cfloop query="data">

               <cfset ArrayAppend(result, lname)>

          </cfloop>

          <cfreturn result>

     </cffunction>

</cfcomponent>

[/code]

 

The query runs fine in a test cfm file.

Any help appreciated.

 
Replies 1 2 Previous Next
  • Currently Being Moderated
    Nov 12, 2012 9:15 AM   in reply to LyndonPatton

    What URL is JS hitting when making the request to employer.cfc? And is employer.cfc at that URL?

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 12, 2012 9:21 AM   in reply to LyndonPatton

    Strictly for troubleshooting, try creating an object from the cfc.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 12, 2012 9:42 AM   in reply to LyndonPatton

    When you use that autosuggest stuff, it writes some Javascript out on the client which calls your CFC remotely when the (I'm guessing) onkeyup event fires on the browser.  So onkeyup (or whichever event it actually is if not that) Javascript will be making an AJAX request back to your server to get what to suggest.  Make sense?  What is the URL it is requesting?

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 12, 2012 9:48 AM   in reply to LyndonPatton

    Dan just wants to check that the CFC actually compiles (well that's my guess).  So just write some code that creates an instance of the CFC, eg:

     

    myObj = new employer();

     

    The next step would be to call the lookupEmployer() method remotely yourself, to see if that works, eg:

     

    http://yourdomain/path/to/employer.cfc?method=lookupEmployer&search=so me%20search%20string

     

    Does that return expected results?

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 12, 2012 10:33 AM   in reply to LyndonPatton

    Adam, I understand how Ajax works... But I have no idea how what url coldfusion uses for the request back????

     

    They same way you'd find out the URL of any AJAX (or otherwise) request being made from the browser: use Firebug - or something - to look at the requests being made.

     

     

    Like I said, the cfm template and the cfc are inj the same folder.

     

    This does not matter.  The CFM is not talking to the CFC; the browser is talking to the CFC.  The browser is talking to the CFC via a URL.

     

    You have this code:

    [code]

    <cfinput type="text" name="Employer" size="50" autosuggest="cfc:employer.lookupEmployer({cfautosuggestvalue})">

    [/code]

     

    All that autosuggest bumpf is doing is telling CF to generate some Javascript - which then gets sent to the browser to be executed when appropriate - to make an AJAX request back to the CF server for it to get some data which it then sends back to the browser to be put in the input box.  There is no connection between the CFM code and the CFC code at all. The CFM generates mark-up and JS and sends it to the browser.  The browser then executes it, and part of the execution might be call back to the CF server - to the CFC - to provide some data for the input box.

     

    Can you please go to my blog and read this article:

    http://adamcameroncoldfusion.blogspot.co.uk/2012/10/the-coldfusion-req uestresponse-process.html

     

    That is specific to "normal" requests, but the same applies to AJAX.  You say you understand this, but I'm not so sure.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 12, 2012 10:41 AM   in reply to LyndonPatton

    " myObj = new employer();"

     

    Is this cfscript? js? a cf tag????

     

    I'm very new, I'm not trying to be a bother but I'm lost here.

     

     

    It's a CFML statement.  The new operator is new to CF9; you could instead to this:

     

    myObj = createObject("employer")

     

    Or use <cfobject> or <cfinvoke> or whatever.

     

    If you're fresh from CF5, you've got a bunch of reading to do, because CFML has moved an awful lot since 2001.

     

    Firstly read these two (all the subpages, I mean):

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461 172e0811cbec1a60c-7ffa.html

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461 172e0811cbec17576-7fef.html

     

    Then this:

    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859 461172e0811cbec22c24-7fec.html (all of it)

     

    Then this:

    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859 461172e0811cbec22c24-7a27.html (again, all of it)

     

    Then try to write code using this stuff.

     

    It's a lot of work, but you've let a lot of water run under the bridge between upgrades.  CFML is a very very different beast in CF9 than it was in CF5.  And the way one writes code is (or at least should be) almost completely different.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 12, 2012 10:59 AM   in reply to LyndonPatton

    I was just hoping to use the cfform built in version for some simple auto suggest needs. Obviously it does not work in CF 9.0.0

     

     

    "you not being able to get it to work" does not equate to "it not working".

     

    You need to know how your tools work and what to do with them before you can hope to use them correctly. I don't think that's too much to expect, is it?

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 12, 2012 12:45 PM   in reply to LyndonPatton

    I have never done this before so I gave it a shot.  I was able to get your error message when I did something stupid in my cfc which caused it to not compile.  The error message is misleading.

     

    Now I'm going to follow my earlier advice of creating the object separately.  Then I'll run my method from that object to make sure it works properly before trying the autosuggest.  I suggest you do the same.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 14, 2012 1:11 AM   in reply to LyndonPatton

    The only difference in my cfc and the one posted in the Ben Forts tutorial blog is the <cfquery> and I kept mine very simple. Mr. Forta responded to the exact same error, in the comments section of the blog post the example/tutorial was published in, for several years and it seems it was never resolved for most users. http://www.forta.com/blog/index.cfm/2007/5/31/coldfusion-ajax-tutorial -1-autosuggest

     

    Not that it's much help, but I copy and pasted Ben's example code - modifying it only to fake the DB call as I don't have that datasource - and it worked fine other than that.  I have not modified my environment in any way to facilitate it working: this is a very bog-standard CF 9.0.1 install.

     

    This is not much help to you, but short of you providing the info I asked, I dunno how we are able to help you further with this.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 14, 2012 3:52 AM   in reply to LyndonPatton

    LyndonPatton wrote:

     

    Actually, given the simplicity of the test code I attempted to use, it absolutely should work. 

    Absolutely. The whole purpose of the exercise is to look up a collection, based on a given search filter. Your query fails to do any filtering at the moment. Modify it to something like

     

    Select distinct lname

    From tdLicense

    Where lname like <cfqueryparam value="#arguments.search#%" cfsqltype="cf_sql_varchar">

    Order By lname

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 14, 2012 4:03 AM   in reply to LyndonPatton

    Oh, and just another idea, in addition to the one I gave earlier, this time more relevant to the question. To rule out any runtime bugs, rename the CFC to employers.cfc and modify the autosuggest attribute to autosuggest="cfc:employers.lookupEmployer({cfautosuggestvalue})". Any joy?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 14, 2012 6:24 AM   in reply to LyndonPatton

    LyndonPatton wrote:

     

    I did the rename suggestion and same error:

     

     

     

    The specified CFC Employer could not be found.

     

     

     

    The path to the CFC must be specified as a full path, or as a relative path from the current template, without the use of mappings

    The specified CFC Employer could not be found.

    The path to the CFC must be specified as a full path, or as a relative path from the current template, without the use of mappings.

    The error occurred in C:\Workgroups\WebPages\binkley\TrackData\NoMenu\test.cfm: line 2
    1 : <cfform name="emp" method="get" >  
    2 : <cfinput type="text" name="Employerx" id="Employerx" size="50" autosuggest="cfc:employer.lookupEmployer({cfautosuggestvalue})"> 
    3 : </cfform> 

     

    I changed the name and id of the input element to something other than the cfc name (grasping at straws)

     

    You have misunderstood me. I suggested you change the name of the CFC file from employer.cfc to employers.cfc. Following the code example you've just given, I am suggesting you rename the file

     

    C:\Workgroups\WebPages\binkley\TrackData\NoMenu\employer.cfc

     

    to

     

    C:\Workgroups\WebPages\binkley\TrackData\NoMenu\employers.cfc

     

    Then modify the cfinput tag accordingly:

     

    <cfinput type="text" name="Employer" size="50" autosuggest="cfc:employers.lookupEmployer({cfautosuggestvalue})">

     

    In fact, another suggestion is, before trying anything else, run the following code on a CFM page:

     

    <cfoutput>#fileExists("C:\Workgroups\WebPages\binkley\TrackData\NoMenu \employer.cfc")#</cfoutput>

     

    If the answer is No, then that will explain why you get the error.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 14, 2012 9:41 AM   in reply to LyndonPatton

    It looks like your directory structure confuses Coldfusion. What is the absolute path of your root directory?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 14, 2012 10:57 AM   in reply to LyndonPatton

    Let's say it is C:\Workgroups\WebPages\binkley. What then do you get when you do this:

     

    <cfinput type="text" name="Employer" size="50" autosuggest="cfc:/TrackData/NoMenu/employer.lookupEmployer({cfautosug gestvalue})">

     

    Probably better:

     

    <cfinput type="text" name="Employer" size="50" autosuggest="cfc:/TrackData.NoMenu.employer.lookupEmployer({cfautosug gestvalue})">

     

     

     

    [added edit: reverted to employer.cfc]

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 14, 2012 12:31 PM   in reply to Adam Cameron.

    The next step would be to call the lookupEmployer() method remotely yourself, to see if that works, eg:

     

    http://yourdomain/path/to/employer.cfc?method=lookupEmployer&search=so me%20search%20string

     

    Does that return expected results?

     

     

    Did you ever do this?

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2012 12:08 AM   in reply to LyndonPatton

    Then binkley was probably not the root directory. In fact, I wondered about WebPages as a possibility(What's in a name?).

     

    In any case, before we proceed any further, verify that the file-name of the CFC you are using is employers.cfc, not employer.cfc as before.

     

    Please let us know what you get when you run the following:

     

    root directory: <cfoutput>#expandpath('/')#</cfoutput>

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2012 5:58 AM   in reply to LyndonPatton

    OK, this is actually getting curious now.

     

    What does this output:

     

    <cfoutput>

    <cfset path ="/">

    #path#: #expandPath(path)#<br />

    <cfset path &= "binkley/">

    #path#: #expandPath(path)#<br />

    <cfset path &= "trackdata/">

    #path#: #expandPath(path)#<br />

    <cfset path &= "Nomenu/">

    #path#: #expandPath(path)#<br />

    <cfset path &= "employers.cfc">

    #path#: #expandPath(path)#<br />

    </cfoutput>

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2012 6:20 AM   in reply to LyndonPatton

    Do me a favour (for the purposes of testing): stick employers.cfc here (make the subdirectories if necessary):

    C:\inetpub\wwwroot\binkley\TrackData\NoMenu\employers.cfc

     

    Oh, and all those paths it output are correct, yes?

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2012 6:21 AM   in reply to LyndonPatton

    Strange. There is apparently a translation from C:\inetpub\wwwroot\ to C:\Workgroups\WebPages\. If that is indeed so, then this should work:

     

    <cfinput type="text" name="Employerx" id="Employerx" size="50" autosuggest="cfc:/binkley/TrackData/NoMenu/employers.lookupEmployer({ cfautosuggestvalue})">

     

    or, using the dotted notation,

     

    <cfinput type="text" name="Employerx" id="Employerx" size="50" autosuggest="cfc:/binkley.TrackData.NoMenu.employers.lookupEmployer({ cfautosuggestvalue})">

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2012 6:54 AM   in reply to LyndonPatton

    LyndonPatton wrote:

     

    Binkley is a virtual directory located at C:\Workgroups\WebPages\binkley on the file system. This is our intranet (protected by application.cfc)...

     

    Our public site, on the same server, is located at c:\wwwroot\inetpub

     

    Thus there is no C:\inetpub\wwwroot\binkley\TrackData\NoMenu\ on the file system.

     

    Does this help?

    

    Yes, it says everything. More later. That was actually the basis of Adam's suggestion to copy the files to C:\inetpub\wwwroot\!

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2012 6:55 AM   in reply to LyndonPatton

    Thus there is no C:\inetpub\wwwroot\binkley\TrackData\NoMenu\ on the file system.

     

     

    Yes, I know that. You know that too.  However I suspect CF does not know that (due to what is seeming more and more like a bug in CF to me).  Hence why I asked to actually create that dir & the file in it, to test that theory.  I'm trying to identify whether CF is looking for C:\inetpub\wwwroot\binkley\TrackData\NoMenu\employers.cfc rather than C:\Workgroups\WebPages\binkley\TrackData\NoMenu\employers.cfc. If we can isolate that being the problem, we can start working on how to work around it.

     

    Note that wherever employers.cfc ends up, it will need to be web browseable, because the client browser will need to access it.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2012 7:04 AM   in reply to Adam Cameron.

    I know what it is.

     

    "Binkley is a virtual directory located at C:\Workgroups\WebPages\binkley on the file system."

     

    A virtual directory is a web server conceit, so is not helping CF locate a CFC.  I suspect yout CF root is C:\inetpub\wwwroot. So that's where CF looks for CFCs. It doesn't know to look anywhere else.

     

    I suspect if you create a CF mapping to /binkley pointing to C:\Workgroups\WebPages\binkley, and reference the CFC in the <cfinput> as binkley.employers, then CF will be able to find it.

     

    ?

     

    --

    Adam

     
    |
    Mark as:
1 2 Previous Next
Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points