ColdBox BE 3.7.1 - Flash Scopes

I am having a weird problem. I can’t explain the problem other than to say its random when the framework starts.

The problem normally happens when I call the MessageBox Plugin and the flash scope is an empty string.

I found a work-around.

In the requestService.cfc under the getFlashScope Function around line 201. I added the following:

if(!isObject(instance.flashScope)){ buildFlashScope(); }

I know this is a hack however it did fix the problem when the flash scope is empty. I should also add once the flash scope is reset, the problem never happens again.

I probably should add that I’m using Railo 4.1.1.003 and its happening on all platforms (windows, mac, & linux/ubuntu).

Any thoughts?

Jeremy R. DeYoung
615.261.8201jeremy.deyoung@lunarfly.comLunarFly.com

Every time I’ve seen that, it’s when you’re trying to call the Flash scope before the framework has fully loaded. The request service is created before the flash scope is initialized because it has to wait for the app config to load. Can you show a complete stack trace?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Brad/Luis,

This problem is getting worse… anything that uses the flash scope is breaking :-(. I’ve included everything possible I can from the local error screen.

The variable “flash” is just an empty string.

Line 103:: flash.put(name=instance.flashKey,value=msg,inflateToRC=false,saveNow=true,autoPurge=false);

flash is empty and therefore has not object to put.

You should know I’m using Railo 4.1.2.005 final on Tomcat 7. However this problem has been happening since Railo 4.1. It appears to affect Windows, Mac, & Linux equally. Also, I’ve updated to the last B.E. ColdBox for the past 6 months hoping the problem resolves itself.

Any insight?

Oops! exception Encountered### Application Execution ExceptionError Type: expression : 0

Error Messages: No matching Method/Function [put] for call with named arguments found

Tag Context:
ID: ??
LINE: 103
Template: C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\plugins\MessageBox.cfc
ID: ??
LINE: 57
Template: C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\plugins\MessageBox.cfc
ID: ??
LINE: 37
Template: C:\tomcat\loc.vencommerce.com\ROOT\model\user\userService.cfc
ID: ??
LINE: 29
Template: C:\tomcat\loc.vencommerce.com\ROOT\handlers\login.cfc
ID: ??
LINE: 764
Template: C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\web\Controller.cfc
ID: ??
LINE: 648
Template: C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\web\Controller.cfc
ID: ??
LINE: 236
Template: C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\Coldbox.cfc
ID: ??
LINE: 38
Template: C:\tomcat\loc.vencommerce.com\ROOT\Application.cfc
Framework Snapshot
Current Event: login.validate
Current Layout: VenCommerce-login.cfm (Module: )
Current View: N/A
Bug Date: 01/09/2014 08:25:56 AM
Coldfusion ID: CFID=38c77966-a9e7-4643-8654-96e1700c59ff ; CFToken=0 ; JSessionID=2B15E16C0089681ABADDF54976ADA227
Template Path : C:\tomcat\loc.vencommerce.com\ROOT\index.cfm
Path Info : /login/validate
Host & Server: loc.vencommerce.com JeremyRDeYoung
Query String:
Referrer: http://loc.vencommerce.com/login
Browser: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.72 Safari/537.36
Remote Address: 127.0.0.1
Form variables:
password:

email:

Session Storage:
Cookies:
railo_admin_lastpage: server.scope
cfid: 38c77966-a9e7-4643-8654-96e1700c59ff
cf_client_adc25351325953f5a0a5886db0c1f0fd: {}
jsessionid: 2B15E16C0089681ABADDF54976ADA227
ace.settings: {“sidebar-collapsed”:1}
railo_admin_pw_server: 6802A0AABEDAB98B97
railo_admin_lang: en
cf_client_adc25351325953f5a0a5886db0c1f0fd_lv: 1389277526735
cf_client_adc25351325953f5a0a5886db0c1f0fd_hc: 1648
cf_client_adc25351325953f5a0a5886db0c1f0fd_tc: 1388074316126
cftoken: 0
Stack Trace:

No matching Method/Function [put] for call with named arguments found 
	at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:746):746
	at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1481):1481
	at coldbox.system.plugins.messagebox_cfc$cf.udfCall1(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\plugins\MessageBox.cfc:103):103
	at coldbox.system.plugins.messagebox_cfc$cf.udfCall(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\plugins\MessageBox.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
	at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:199):199
	at railo.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:713):713
	at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:739):739
	at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1481):1481
	at coldbox.system.plugins.messagebox_cfc$cf.udfCall1(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\plugins\MessageBox.cfc:57):57
	at coldbox.system.plugins.messagebox_cfc$cf.udfCall(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\plugins\MessageBox.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:212):212
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:623):623
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:506):506
	at railo.runtime.ComponentImpl.call(ComponentImpl.java:1732):1732
	at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:713):713
	at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1471):1471
	at model.user.userservice_cfc$cf.udfCall(C:\tomcat\loc.vencommerce.com\ROOT\model\user\userService.cfc:37):37
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
	at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:199):199
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:624):624
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:506):506
	at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1749):1749
	at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:739):739
	at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1481):1481
	at handlers.login_cfc$cf.udfCall(C:\tomcat\loc.vencommerce.com\ROOT\handlers\login.cfc:29):29
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
	at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:199):199
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:624):624
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:506):506
	at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1745):1745
	at railo.runtime.tag.Invoke.doComponent(Invoke.java:203):203
	at railo.runtime.tag.Invoke.doEndTag(Invoke.java:176):176
	at coldbox.system.web.controller_cfc$cf.udfCall6(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\web\Controller.cfc:764):764
	at coldbox.system.web.controller_cfc$cf.udfCall(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\web\Controller.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:212):212
	at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:704):704
	at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:713):713
	at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1471):1471
	at coldbox.system.web.controller_cfc$cf.udfCall5(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\web\Controller.cfc:648):648
	at coldbox.system.web.controller_cfc$cf.udfCall(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\web\Controller.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
	at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:199):199
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:624):624
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:506):506
	at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1749):1749
	at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:739):739
	at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1481):1481
	at coldbox.system.coldbox_cfc$cf.udfCall1(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\Coldbox.cfc:236):236
	at coldbox.system.coldbox_cfc$cf.udfCall(C:\tomcat\loc.vencommerce.com\ROOT\coldbox\system\Coldbox.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:212):212
	at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:704):704
	at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:713):713
	at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1471):1471
	at application_cfc$cf.udfCall(C:\tomcat\loc.vencommerce.com\ROOT\Application.cfc:38):38
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:212):212
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:623):623
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:506):506
	at railo.runtime.ComponentImpl.call(ComponentImpl.java:1732):1732
	at railo.runtime.listener.ModernAppListener.call(ModernAppListener.java:387):387
	at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:113):113
	at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:18):18
	at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2135):2135
	at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2102):2102
	at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:332):332
	at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728):728
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51):51
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243):243
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210
	at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176):176
	at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145):145
	at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92):92
	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381):381
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243):243
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222):222
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123):123
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502):502
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171):171
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100):100
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953):953
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408):408
	at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603):603
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310):310
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source):-1
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source):-1
	at java.lang.Thread.run(Unknown Source):-1

Extra Information Dump
[N/A]

That request looks like an ordinary request where the framework should be loaded. The flash scope is normally build at the beginning of the registerAspects() method in LoaderService when the framework is coming up. Can you put in some logging to see if that is getting reached as well as some logging in loaderService.loadApplication()? I’m curious if something is redirecting to a different page, aborting, or erroring out while the framework is coming up and preventing it from completing the process. Come to think of it, put some logging in MessageBox.cfc as well. As a plugin, it asks the RequestService for the flash scope and keeps a reference to it. The MessageBox plugin could be getting created too soon in the reinit process and grabbing the flashscope before it’s been built.

Between loaderService.loadApplication(), loaderService.registerAspects, and Messagebox.init(), that should give us an idea of what’s getting executed and in what order.

It might not be a horrible idea to put some check in RequestService.getFlashScope() to not return flash if it hasn’t been built. We could throw an error. The issue with building it is, if the config hasn’t been parsed, what storage would we use? Defaulting to “session” would error if someone had the session scope disabled.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Jeremy,

I am confused, the actual error message is probably coming from your userService line 37. Any chance you could show us that line of code.

Andrew!

UserService.cfc

Line 37 :: messageBox.error(‘Your login attempt failed. Please try again later!’);

Thanks for your help with this!

Same issue, Coldbox 3.8

The trigger is a MessageBox.error inside a handler action - nothing special.

MessageBox variable is injected via property - again pretty standard:
property name=“MessageBox” inject=“coldbox:plugin:MessageBox”;

There should definitely be a check in getMessage and setMessage to make sure flash is ready - so there’s a clear error message as to what’s wrong, instead of the obscure “Cannot invoke method put on an object of type java.lang.String with named arguments.”

Only needs to be a simple:

if ( NOT isObject(flash) ) throw (message=“Flash scope not initialised”,type=“whatever”);

As for what’s actually happening - a few dumps suggest that buildFlashScope is initially being setup, so presumably it’s being reset/overwritten at some later stage.

Not sure if I’ll have time to dig further than that, but will update if I find out more.

Ok, so the problem is not limited to MessageBox - this is just where it manifests itself.

The issue is that certain plugins are being loaded before the flash scope is built - i.e. before LoaderService.registerAspects is called.

It seems to be interceptor related - i.e. the plugin initing is occurring with the InterceptorService.onConfigurationLoad function.

I’ve not tracked it down further than that yet - just posting an update before I go eat.

We’re using both built-in and custom interceptors, so I presume it must be something in the latter otherwise I’d expect it to be a more common problem, but will find out either way later.

Ok, so I’ve got to the bottom of the issue now.

MessageBox is being injected into some services, which are being resolved before the buildFlashScope call.

The interceptor thing is just the first time coldbox encounters those CFCs - i.e. if the relevant interceptors are disabled, the plugins still get injected too early, I think via ModuleService.activateAllModules call.

In this situation I can probably refactor the MessageBox use into the relevant handlers, and avoid modifying requestservice.cfc

But in general, that still means interceptors and module models can’t use plugins that use the flash scope, and will silently create an invalid instance of such plugins.

If this is desired behaviour then getRequestService().buildFlashScope needs to be called earlier (or alternatively use the code Jeremy posted to re-init when needed).

If it’s not desired behaviour, Coldbox should throw an error inside the init of MessageBox (and any other plugin that depends on flash scope to work), pointing out that it cannot be used at that stage.

This is fixed now on the dev branch.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

SWEET! I’m glad I wasn’t crazy. I seriously thought it was only happening to me :frowning: hahaha

LUIS you’re awesome as always!

signature0.jpg

And Peter - You’re awesome b/c you did what I couldn’t! Prove the problem!

signature0.jpg