apache - 在 application.cfc 中调用命令在 railo 4.1 中失败(错误 : missing required argument [object])

标签 apache tomcat coldfusion railo cfml

我正在从 Railo 3 升级到 4,并且遇到了旧 Application.cfc 的问题。 Application.cfc 在 OnRequest 方法中的以下行失败:

content = invoke(controller = controllerPath, method = URL.action, arguments = {'data':FORM,'options':URL});

这是错误的部分内容:

Railo 4.1.1.009 Error (template)

Message missing required argument [object] for function [invoke]

Pattern invoke(object:any, name:string [, arguments:any]):object

Documentation invokes a function/operation of the given object and if given object is a string, Railo tries to load as component.

Required:

  • object (any): a component, struct or scope that holds a function, can also be the name of a component, in this case the component get loaded.
  • name (string): name of the function/operation

Optional:

  • arguments (any): arguments to pass to the function/operation

Stacktrace The Error Occurred in /home/admin/quicktrackweb/src/web/cf3/Application.cfc: line 215

213: dynFunc = view[URL.action];

214:

215: content = invoke(controller = controllerPath, method = URL.action, arguments = {'data':FORM,'options':URL});

216: //content = "test";

217: if (GetMetaData(dynFunc).access == 'remote') {

Java Stacktrace missing required argument [object] for function [invoke] at railo.transformer.bytecode.expression.var.Variable.getMatchingValueAndType(Variable.java:700):700 at railo.transformer.bytecode.expression.var.Variable._writeOutFirstBIF(Variable.java:458):458 at railo.transformer.bytecode.expression.var.Variable._writeOutFirst(Variable.java:419):419 at railo.transformer.bytecode.expression.var.Variable._writeOut(Variable.java:238):238 at railo.transformer.bytecode.expression.var.Variable._writeOut(Variable.java:219):219 at railo.transformer.bytecode.expression.ExpressionBase.writeOut(ExpressionBase.java:34):34 ...

这是 OnRequest 方法:

    public void function OnRequest (required string TargetPage) {
            var content = '';
            var controllerPath = '';
            var dynFunc = '';
            var isDebug = false;
            var output = '';
            var response = '';
            var templatePath = 'views/login/login.cfm';
            var toolbar = CreateObject('component', 'controllers.toolbar');
            var view = '';
            import 'controllers.ajax';
                    //ssl implemtation
            if (!CGI.SERVER_PORT_SECURE) {
                    Location("http://#CGI.SERVER_NAME#/?#CGI.QUERY_STRING#", false);
            }


            param name='URL.view' type='string' default='home';
            param name='URL.action' type='string' default='';
            param name='URL.id' type='numeric' default=0;
            param name='URL.options' type='string' default='';

            URL.view = REReplace(URL.view, '\W', '', 'all');

            if (StructKeyExists(URL, 'faq')) {
                    templatePath = "views/home/faq.cfm";    
            } else if (SESSION.user.id || (URL.view == 'login' && URL.action == 'new')) {
                    if (StructKeyExists(GetHttpRequestData().headers, 'ajax')) {
                            var ajax = new ajax(request = GetHttpRequestData(), url = URL, form = FORM, cookie = COOKIE);

                            Header(name = 'Content-Type', value = 'application/json');
                            WriteOutput(ajax.getResponse());

                            return;
                    } else {
                            if (URL.action == '') {
                                    URL.action = ListGetAt(URL.view, ListLen(URL.view, '.'), '.');  
                            }

                            if (hasFunction('controllers.' & URL.view, URL.action) || hasFunction('controllers.#URL.view#.#URL.view#', URL.action)) {
                                    if (hasFunction('controllers.' & URL.view, URL.action)) {
                                            controllerPath = 'controllers.#URL.view#';
                                    } else {
                                            controllerPath = 'controllers.#URL.view#.#URL.view#';
                                    }

                                    view = CreateObject('component', controllerPath);
                                    dynFunc = view[URL.action];

========> Line where app fails:         content = invoke(controller = controllerPath, method = URL.action, arguments = {'data':FORM,'options':URL});

                                    if (GetMetaData(dynFunc).access == 'remote') {
                                            GetPageContext().getResponse().reset();
                                            Header(name = 'Content-Type', value = 'application/json');
                                            WriteOutput(content);
                                            return; 
                                    }

                                    templatePath = '';      
                            } else if (FileExists("views/#URL.view#/#URL.view#.cfm")){
                                    templatePath = "views/#URL.view#/#URL.view#.cfm";
                            } else{
                                    templatePath = "views/home/home.cfm";
                            }
                    }
            }

            if (content == '' && FileExists(templatePath)) {
                    savecontent variable = 'content' {include '#templatePath#';}    
            }

            if (CGI.SCRIPT_NAME == '/js/webapp.cfm') {
                    Header(name = 'Content-Type', value = 'application/javascript');
                    include '/js/webapp.cfm';
            } else if (CGI.SCRIPT_NAME == '/css/webapp.cfm') {
                    Header(name = 'Content-Type', value = 'text/css');
                    include '/css/webapp.cfm';
            } else {
                    include '/index.cfm';
            }

            //Return out.
            return;
    }

很抱歉爆破所有这些代码,但由于我对 Railo/CF 还很陌生,所以我不确定从哪里开始。 invoke 是否已被弃用,我应该用什么来代替它?

调用似乎与之前的版本完全不同,因为它需要一个参数“object”,但我有参数“controller”、“method”和“arguments”

我的 Railo 版本是 4.1.1.009 我在装有 Apache 2.2.22 和 Tomcat 7.0.20 的 Ubuntu 服务器上运行

最佳答案

回到 Railo 3.3.4.003 final,匹配生产服务器,它就可以工作了。 3.3.4.003 确实具有与 9.0.0.1 的 ColdFusion 兼容性。我认为这就是它现在工作的原因,除了删除检查 !CGI.SERVER_PORT_SECURE 的 http 重定向之外,我不必对 Application.cfc 中的代码进行任何更改(导致重定向循环,我对此进行了评论出)。

如果我的想法在这里有误,请告诉我。

关于apache - 在 application.cfc 中调用命令在 railo 4.1 中失败(错误 : missing required argument [object]),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20060031/

相关文章:

apache - 在 CentOS 上启动 Tomcat 服务器会使在 Apache 上运行的 PHP 站点崩溃

tomcat - 文档 base/usr/share/tomcat7/webapps/ROOT 不存在或不是可读目录

coldfusion - 如何使用 cfscript 而不是 cfmail 构建复杂的电子邮件 - 模板加上保存在变量中的内容?

javascript - 为什么 ColdFusion 纪元时间比 javascript 纪元时间晚一小时?

coldfusion - 在onError函数中引发错误时,为什么没有递归无限循环?

phpinfo 说 php.ini 路径是 C :\Windows but there is no php. ini

java - Maven2有哪些隐藏特性?

java - 如何以编程方式确定我们在桌面上而不是在应用程序服务器上(显示弹出窗口)?

java - 抑制 Apache Tomcat stdout 上的警告

java - JSF - 带参数的调用方法(tomcat6)