Skip to main content
May 2, 2011
Answered

Question with application.cfc file

  • May 2, 2011
  • 2 replies
  • 819 views

I have the following segment in my application.cfc file:

<cffunction name="onApplicationStart" returnType="boolean" output="false">

<cfset application.portfolioUploadRoot = "c:\test">

        <cfset application.ftpUser="commuser">

        <cfset application.ftpUserPass="74pA9yDo">

        <cfset application.commExch="icsscohtvp02.ics.idaho.net">

<cfif not directoryExists(application.portfolioUploadRoot)>

<cfdirectory action="create" directory="#application.portfolioUploadRoot#">

</cfif>

<cfreturn true>

</cffunction>

If I do a cfdump of #application.ftpUser it gives me the info listed above.

If I do a cfdump of #application.commExch#, I get

Element  COMMEXCH is undefined in APPLICATION.

Why would this be occuring???

    This topic has been closed for replies.
    Correct answer Amiya_Padhi

    First of all as a tip I want to say Please use Application.cfc instead of application.cfc.

    Then do a cfdump of application scope and ant let us know the output.

    2 replies

    Amiya_PadhiCorrect answer
    Participating Frequently
    May 2, 2011

    First of all as a tip I want to say Please use Application.cfc instead of application.cfc.

    Then do a cfdump of application scope and ant let us know the output.

    May 2, 2011

    Restarting the server worked perfectly.  Thanks for the suggestion

    12Robots
    Participating Frequently
    May 2, 2011

    Personally, I find that to be the least-desirable option, in dev or production.

    If I were you I would look more into implementing option 3.  It's pretty simple.

    <cffunction name="onRequestStart">

    <cfif structKeyExists(URL, "reinit")>

    <cfset onApplicationStart() />

    </cfif>

    </cffunction>

    Then, anytime you want to reinit the app you just need to add &reinit tot he URL string (or ?reinit if it is the only URL param).

    Jason

    12Robots
    Participating Frequently
    May 2, 2011

    Did you add the code for commExch after you had run the application atleast once?

    onApplicationStart ONLY runs the first time the application is started.  If you add code to it after the app is running, it will not run again. There are a few things you can do.

    1. Restart ColdFusion

    2. Rename the application so that you start a new one (this.name="app2")

    3. Reinit your app in onRequestStart()

    <cffunction name="onRequestStart">

    <cfset onApplicationStart() />

    </cffunction>

    I do not recommend leaving option 3 in place in production. Most developers, if they employ option 3, will wrap it in an IF statement that looks for a certain URL param so they can reinit ondemand.

    Good luck