Skip to main content
May 7, 2007
Question

CFC invokes kill the page

  • May 7, 2007
  • 3 replies
  • 416 views
Hi all,

I've used CFC's before just fine but for some reason the same code that works locally is dying on the live server. For example, in my application.cfc I have this...

<cffunction name="onApplicationStart" returnType="boolean" output="false">
<cfset application.system = createObject("component", "system") />
<cfreturn true />
</cffunction>

Then in my template I have something like...

<cftry>
<cfinvoke component="system" method="getItems" returnvariable="items">
<cfinvokeargument name="item_id" value="#url.item_id#" />
</cfinvoke>
<cfcatch type="any"><p class="error"><strong>Problem Invoking CFC Method</strong></p></cfcatch>
</cftry>

Everytime I execute the page I get the message from the cftry block. If I remove the cftry tags, everything AFTER the invoke is blank and it's killed everything - but no native Coldfusion error occurs s I'm a bit lost as to what's causing it.

One thing to note here is that this is a seperate application.cfc to another above it and everything I'm working on is in it's own folder so it shouldn't be a problem. The folder is also mapped as a sub-domain...would that make any difference?

Another thing I noticed is that if I navigate directly to the cfc through the browser, it just looks blank instead of presenting me with the coldfusion administrator like it normal should. e.g. if i type the path... http://mysubdomain.mysitewhatever.com/cfc/system.cfc (i changed the sub domain and site name for security but the structure is the same)

Any help with this would be much appreciated.

Regards,

Michael.

here's my web site structure:

- main website (folder)
- application.cfc
- index.cfm

- subdomain (folder)
- - application.cfc
- - index.cfm
- - cfc (folder)
- - - system.cfc
    This topic has been closed for replies.

    3 replies

    May 8, 2007
    Indeed, even if I use the cfobject tag it returns blank, no errors nothing...

    <cfobject component="cfc.system" name="system" />

    <cfparam name="url.item_id" type="numeric" default="0" />
    <cfinvoke component="#system#" method="getItems" returnvariable="items">
    <cfinvokeargument name="item_id" value="#url.item_id#" />
    </cfinvoke>

    Surely my syntax is not incorrect. If it is please let me know, but even then I've tried numerous combinations.

    Thanks.
    Inspiring
    May 8, 2007
    OK, Captain, it looks to me like your syntax is NOT correct.

    From what I can see, when you instantiate your CFC, it should be:
    <cfobject name="application.system"
    component="main_website_folder.Subdomain_folder.Cfc_folder.system"/>

    or (I like this better, it’s a matter of personal preference):

    <cfset application.system = createObject(“component”, “main_website_folder.Subdomain_folder.Cfc_folder.system”)>

    Also, remember that these dot-notated paths may not be the same on your live server as on your ‘localhost’, depending on how your site is structured.

    You can neither <cfoutput> nor <cfdump> the entire component; you must call one of the functions in the CFC, then you can <cfoutput> that. For example:

    <CFSET someVariable = APPLICATION.system.someFunction() > and then,

    <cfoutput>#some Variable#</cfoutput>

    Try it, I think you’ll like it.

    Carlos
    May 8, 2007
    Hi,

    Even if I try that it doesn't work. If I even try and print out the application variable:

    <cfoutput>#application.system#</cfoutput>

    It kills everything and is just blank. I don't really understand why this would happen.

    Thanks.
    Inspiring
    May 7, 2007
    Without even getting into this, if you are setting ‘Application.system’, you should be invoking ‘Application.system’, not just ‘system’.