Skip to main content
Known Participant
January 26, 2011
Question

application.cfc - definition of APPLICATION variables

  • January 26, 2011
  • 4 replies
  • 1994 views

I started to have logs in coldfusion 8 administrator about my variables which are in application.cfc.

------ log-----

"Could not find the ColdFusion Component or Interface cfcs.cfcfile.

Ensure that the name is correct and that the component or interface exists. "

--------------

Everywhere in website I use invoke with variable APPLICATION.cfcApp, so I dont have to write always folder.cfcs.cfcfile:

<cfinvoke component="#APPLICATION.cfcApp#"  method="someMethod"   returnvariable="retVar" >   

In my application.cfc I have:

<cffunction name="onRequestStart"  returntype="boolean" output="true">

  <cfset APPLICATION.datasource = "xxxx">

  <cfset APPLICATION.CFCRootPath ="xxxx">

   <cfset APPLICATION.username = "xxxx">  

  <cfset APPLICATION.passport = "xxxx">

  <cfset APPLICATION.cfcApp= "folder.cfcs.cfcfile">

  <cfreturn true>

</cffunction>

Why I have sometimes that record in logs ?

Thanks for help.

    This topic has been closed for replies.

    4 replies

    Participating Frequently
    January 27, 2011

    This whiole thread we all assumed that the application variable was not beign set. However, from the error message you posted it is being set, its just that ColdFusion cannot find the file you are lookign for.

    Check your path to the file.

    alex_cvAuthor
    Known Participant
    January 27, 2011

    Thank you.

    The path is correct, because coldfusion can find it most of the time. I have this logs just sometimes, maybe once a week or so

    What I am asking is , why I have this logs just sometimes? Why coldfusion can not find it sometimes and most of time it can?

    Is it problem that website is running on server with  Coldfusion 8 Standard with another 50 ..  pages?

    Application variable should be created for each page.

    Inspiring
    January 27, 2011

    Yeah, I think Scott's right, looking at the error more closely.  I was focussing on the application variables because I initially noticed they are being set in an inappropriate place (ie: onRequestStart, not onApplicationStart), and kinda got stuck on that.

    It's "clearly" (well: clearly now that I actually read it ;-) saying it can't find the CFC, not that it can't find the variable.

    However it's saying it can't find cfcs.cfcfile, not that it can't find what you're actually setting that variable to be: folder.cfcs.cfcfile (although I'm guessing that's an example, as otherwise it's a bit of a poorly conceived path...).

    So it looks to me like:

    a) that variable gets changed to be the wrong value at some point;

    b) you have a reference to cfcs.cfcfile somwhere, rather than application.cfcApp.

    Check both of those.

    --

    Adam

    Inspiring
    January 26, 2011

    Are you sure those requests that are error are in a path that will find that Application.cfc?  They're not in some adjacent directory structure, or there isn't another Application.cfc (or Application.cfm) file between them and the Application.cfc you want, is there?

    Also, as an aside: don't set and reset your application variables every request.  Set them once in onApplicationStart().  This is just "thoughtful coding", and will not actually impact your issue.

    --
    Adam

    alex_cvAuthor
    Known Participant
    January 27, 2011

    Actually, I have to 2 Application.cfc files on site. One is in root directory and another one is in Admin directory.In each of them I use onRequestStart method where I set my Application.variables like datasource, username,password and cfcs.cfcFIle.

    Participating Frequently
    January 26, 2011

    This is a great use case for an application specifc mapping, rather than an application scope variable.

    Inside your <cfcomponent> tag in Application.cfc, but NOT in a mehtod, you could add the following:

    <cfset this.mappings["/cfcs"] = {the absolute path to the 'cfcs' directory} />

    Then in your code you can just use cfcs.cfcFIle to reference the CFC.

    alex_cvAuthor
    Known Participant
    January 27, 2011

    If I use mappings, in Application.cfc, how would I cfinvoke some method?

    Would it be like this:

    <cfinvoke component="#cfcs.cfcFIle#"  method="someMethod"   returnvariable="retVar" >

    Thank you.

    Participating Frequently
    January 27, 2011

    <cfinvoke component="cfcs.cfcFile" method="someMethod" ... >

    BKBK
    Community Expert
    Community Expert
    January 26, 2011
    In my application.cfc I have:

    Renaming the file to Application.cfc might help.

    alex_cvAuthor
    Known Participant
    January 27, 2011

    I'm sorry I made mistake, name of the file is Application.cfc.