1

I'm using Coldfusion8 and am stuck trying to call a component. This worked up until a few days ago and although I can't recall changing anything, all my calls to this component now fail.

Here the code:

<cfinvoke component="form_mailer_user" method="msg_contact">
     <cfinvokeargument name="userData" value="#Local.User#"/>
</cfinvoke>  

Nothing special really except maybe for passing a struct are argument.

I'm getting the following error:

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

It exists allright... so what can I do to try and access it?

Thanks for help!

EDIT:
Both files are in the same folder called services. I have a mapping for this folder in my application.cfc

THIS.mappings["/services"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "services";

But trying to call the component like so:

services.form_mailer_user
services.form_mailer_user.cfc

also does not work.

EDIT:
My application.cfc

<cfcomponent displayname="Application" output="false" hint="Application handler">   
    <cfscript>
        THIS.name = "abc";
        THIS.sessionManagement = "true";        
        THIS.sessionTimeout = createTimeSpan(0,2,0,0);
        THIS.s3.acceesKeyid = "___";
        THIS.s3.awsSecretKey = "___";
        // mappings
        THIS.mapping = {};
        THIS.mappings["/controllers"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "controllers";
        THIS.mappings["/services"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "services";
    </cfscript>

    <cffunction name="onApplicationStart" returnType="boolean" output="false" hint="">
        <cfscript>
            Application.strConfig = structNew();
            Application.strConfig.datasource = "___";
            Application.strConfig.rootDir = "test/members/";
            Application.strConfig.emailErrorMessaging = "on";
        // pre
            Session.activeSession = "No";
            Session.activeLog = "No";
        </cfscript>
        <cfreturn true />
    </cffunction>

    <cffunction name="onSessionStart" returnType="boolean" output="false" hint="session initalizer">
        <cfscript>
            var Local = {};
            Local.cfid = Session.cfid;
            Local.cftoken = Session.cftoken;
            StructClear( SESSION );
        </cfscript>

        <!---SESSION  --->
        <cfparam name="Session.log" default="">
        <cfparam name="Session.activeLog" default="No">
        <cfscript>
            Session.cfid = Local.cfid;
            Session.cftoken = Local.cftoken;
            Session.activeSession = "Yes";              
            Session.datasource = Application.strConfig.datasource;
            Session.testpath = "tes/";
            Session.tpu = "../";
            Session.bucketPath = "http://s3.amazonaws.com/";
            Session.bucketName = "___";
        </cfscript> 
        <cfreturn true />
    </cffunction>

    <cffunction name="onRequestStart" returnType="boolean" output="false" hint="Pre page processing!">         
        <cfscript>
            var LOCAL = {};             
        </cfscript> 
        <!--- DEBUG --->
        <!---
            <cfif structKeyExists(url,'reset')>
                <cfcache action="flush">
                <cfset OnApplicationStart() />
                <cfset THIS.OnSessionStart() />
            </cfif>
            --->
            <cfif len( Session.errMsgs ) EQ 0> 
                <cfinvoke component="services.errorMsg" method="createErrMsgsLog" returnvariable="errMsgs"></cfinvoke>
                <cfset Session.errMsgs = errMsgs> 
            </cfif> 
        <cfreturn true />
    </cffunction>
    <!--- custom functions --->
<cfinclude template="templates/tmp_functions.cfm">
</cfcomponent>

EDIT:
I think I'm getting closer. I have another mailer (same folder) and I just swapped this one in replacing my

 <cfinvoke component="form_mailer_other" method="msg_contact">
     <cfinvokeargument name="userData" value="#Local.User#"/>
</cfinvoke>

Now Coldfusion can't find the method, but this means it found the cfc. Could it be an error inside my mailer.cfc then?

SOLUTION:
I'm afraid to tell...

Typo in the filename from_mailer_user ... Thanks everyone for helping out!

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
frequent
  • 27,643
  • 59
  • 181
  • 333
  • What directory is the CFM doing the cfinvoke and where is the CFC located? Based on the call you are doing they must be in the same directory. – BKK Aug 19 '12 at 22:06
  • yes, they are in the same directory (I also have a mapping for this directory, but using it also does not work). The CFC being called handles all my email messages being sent, so I'm passing a struct with contact details etc and send out the messages from the user_mailer.cfc – frequent Aug 19 '12 at 22:11
  • Please post your application.cfc What operating system are you on? This may be a long shot but try adding & "services/" trailing slash to your mappings statement. – BKK Aug 19 '12 at 22:19
  • Coldfusion8/MySQL 5.0.88. Apache, running Windows (I believe). Application.cfc coming up. – frequent Aug 19 '12 at 22:20
  • Try also swapping to: GetBaseTemplatePath() instead of currentTemplatePath – BKK Aug 19 '12 at 22:23
  • I tried your application.cfc under CF9 and it worked fine, unfortunately I don't have CF8 for testing purposes anymore. I would try creating a test.cfm and try mapping to the CFC using a hardcoded path first and see if you run into similar issues. Point of note in your Application.cfc is that you are setting a struct called this.Mapping = {} instead of this.Mappings = {} but it shouldn't matter. I don't think you have to initialize the struct anyway. Have you restarted the application recently? Quick way is to just rename the this.name or issue an ApplicationStop(); I'm stumped! – BKK Aug 19 '12 at 22:49
  • Solution: Typo -> Ahhhhh! :D (Ah well) – BKK Aug 19 '12 at 22:50
  • @BenKoshy: thanks for the input. I just found the problem... the component was named `from_mailer_user.cfc` vs. `form_mailer_user.cfc`. Guess it's just too late here... If you want to make your above comment an answer I will check and upvote. Thanks for helping out! – frequent Aug 19 '12 at 22:50

2 Answers2

3

if the CFC and CFM file are not in the same directory you need to add the directory name where the CFC is located with a dot. See below. (directory.form_mailer_user)

1

Add the attribute access="public" in the definition of the methods you can't "see" like this:

<cffunction name="onRequestStart" access="public" returnType="boolean" output="false" hint="Pre page processing!"> ...
boycaught
  • 15
  • 4
  • got it to work in the meantime also using `access="public"`, so maybe that was it. – frequent Mar 10 '13 at 19:58
  • 3
    access="public" should allow any other CFC on your server to access methods in the called CFC. "Private" methods can only be invoked from within the CFC. "Package" allows CFCs in the same directory to communicate, and "remote" can be called from different servers (i.e. web services.) Glad to see you got it fixed. – boycaught Mar 10 '13 at 23:01