【发布时间】:2012-08-15 08:23:50
【问题描述】:
我正在使用 Coldfusion8 并且一直在尝试调用组件。这一直持续到几天前,虽然我不记得改变了什么,但我对这个组件的所有调用现在都失败了。
代码如下:
<cfinvoke component="form_mailer_user" method="msg_contact">
<cfinvokeargument name="userData" value="#Local.User#"/>
</cfinvoke>
除了可能传递一个结构是参数之外,没有什么特别的。
我收到以下错误:
Could not find the ColdFusion Component or Interface form_mailer_user.
Ensure that the name is correct and that the component or interface exists
它确实存在...那么我该怎么做才能尝试访问它?
感谢您的帮助!
编辑:
这两个文件都位于名为services 的同一文件夹中。我的 application.cfc 中有这个文件夹的映射
THIS.mappings["/services"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "services";
但是尝试像这样调用组件:
services.form_mailer_user
services.form_mailer_user.cfc
也不行。
编辑:
我的应用程序.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>
编辑:
我想我越来越近了。我有另一个邮件(同一个文件夹),我只是换了这个来替换我的
<cfinvoke component="form_mailer_other" method="msg_contact">
<cfinvokeargument name="userData" value="#Local.User#"/>
</cfinvoke>
现在 Coldfusion 找不到方法,但这意味着它找到了 cfc。那会不会是我的 mailer.cfc 中的错误?
解决方案:
我不敢说...
from_mailer_user 文件名中的错字...感谢大家的帮助!
【问题讨论】:
-
CFM 执行 cfinvoke 的目录是什么,CFC 位于何处?根据您正在进行的呼叫,它们必须位于同一目录中。
-
是的,它们在同一个目录中(我也有这个目录的映射,但使用它也不起作用)。被调用的 CFC 处理我发送的所有电子邮件,所以我传递了一个包含联系方式等的结构,并从 user_mailer.cfc 发送消息
-
请发布您的 application.cfc 您使用的是什么操作系统?这可能是一个长镜头,但请尝试在您的映射语句中添加 & “services/” 斜杠。
-
Coldfusion8/MySQL 5.0.88。 Apache,运行 Windows(我相信)。 Application.cfc 即将推出。
-
也尝试换成:GetBaseTemplatePath() 而不是 currentTemplatePath
标签: coldfusion coldfusion-8 cfc application.cfc cfinvoke