Skip to main content
Inspiring
May 16, 2008
Question

Invoking component from cffunction

  • May 16, 2008
  • 5 replies
  • 3024 views
Hi all,

I had a script in CF7 that used cfinvoke to call a cffunction from inside a different cffunction tag within the same cfcomponent tag. This all worked fine on my old CF7 server, but now on a new CF8 server it throws an error saying "Could not find the ColdFusion Component or Interface CFC.shoppingCart."

Any ideas anyone?

Thanks, Paul

    This topic has been closed for replies.

    5 replies

    BKBK
    Community Expert
    Community Expert
    May 17, 2008
    All's well that ends well.




    BKBK
    Community Expert
    Community Expert
    May 17, 2008
    Could there be a name/type clash? What happens when you give the function a new name?

    Inspiring
    May 17, 2008
    BKBK,

    I have recently changed the returned variable name as it was the same as the calling function and having tested in a different browser, it seems to work now.

    I suspect that was the cause from the beginning - I never had that problem with CF7.1 though. Something new in CF8?
    BKBK
    Community Expert
    Community Expert
    May 17, 2008
    If you get the same error, then you're calling the function from a page relative to which the CFC's path is different from CFC.shoppingCart. There are three paths to consider. What is the path of the shoppingCart CFC, of the page containing the function and of the page that calls the function?

    Inspiring
    May 17, 2008
    BKBK,

    The calling page is mysite.com/page.cfm and it calls the cfc as cfc.shoppingCart.
    The shoppingCart cfc is mysite.com/cfc/shoppingCart.cfc

    The error it gives is Entity has incorrect type for being called as a function.

    Thanks,
    Paul
    Inspiring
    May 16, 2008
    Trying to get a shared hosting provider to restart a service on their boxes can be quite a frustrating task. If for some reason you can't test the application on a local development machine, you could always just change the name of the CFC and test against the new CFC. You shouldn't have any problems with coldfusion pointing to an old version of the component.
    Inspiring
    May 16, 2008
    > "Could not find the ColdFusion Component or Interface CFC.shoppingCart."

    > <cfinvoke component="CFC.shoppingCart" method="getCartProduct"
    > returnvariable="getCartProduct">


    Can you browse to http://yoursite/CFC/shoppingCart.cfc?

    Do you have a CF mapping called CFC, pointing to the dir that has
    shoppingCart.cfc in it?

    CF needs to know how to find the CFC file.


    --
    Adam
    Inspiring
    May 16, 2008
    Outside5.com wrote:
    >
    > There are various other functions within the site that use functions from this
    > cfc without issue, but it seems to fall down at the point where a cffunction
    > uses cfinvoke to call another cffunction in the same cfcomponent.
    >
    > Thanks,
    > Paul
    >

    If the function in question is inside the component of which the
    <cfinvoke...> tag is accessing another function; then you do not need
    the component='' property. This property is used to tell the CFML
    engine where to find the component. Since it is already inside the
    component you want it to use you do not need to tell it to find the
    component somewhere else. And since you do not have a 'cfc' mapping,
    ColdFusion is looking for that location relative the the template making
    the call. In this case the template is already inside the 'cfc'
    directory and parameter 'cfc.shoppingCart' is looking for another 'cfc'
    directory under the 'cfc' directory it is already in. I.E.
    'cfc.cfc.shoppingCart.cfc' and it can not find that.

    All that to say try this:

    <cfinvoke method="getCartProduct" returnvariable="getCartProduct">

    Inspiring
    May 16, 2008
    Thanks Ian,

    I see what you mean and it certainly makes sense. It doesn't however fix my problem :(

    This is frustrating. I have identical files running on identical databases on two different servers, one on CF7 works and the other on CF8 does not.

    Are there any differences between CF7 and CF8 that would/could affect this?

    Thanks,
    Paul

    Error Message is:

    Could not find the ColdFusion Component or Interface CFC.shoppingCart.
    Ensure that the name is correct and that the component or interface exists.

    Error Occurred While Processing Request
    Could not find the ColdFusion Component or Interface CFC.shoppingCart.
    Ensure that the name is correct and that the component or interface exists.

    The error occurred in D:\site\wwwroot\cfc\shoppingCart.cfc: line 113

    111 : <cfloop query="getCart">
    112 : <cfinvoke method="getCartProduct" returnvariable="getCartProduct">
    113 : <cfinvokeargument name="pId" value="#pId#">
    114 : </cfinvoke>