[ColdBox 3.6.0] Rest on railo with orm randomly fails

Could please someone explain me why this code randomly throws exception?

local.dashboard = dashboardService.get(1);
dashboard.setName(obj.name);
dashboard.setLayout(“test”);
dashboard.setUpdated_at(Now());
populateModel(model=local.dashboard, exclude=“id”);
dashboardService.save(local.dashboard);

event.renderData(data=local.dashboard, type=“json”);

The error says:

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

**Error Messages:**key [DASHBOARD] doesn’t exist in struct (keys:)

Probably because you’re randomly switching back and forth between scoped and non-scoped variables.

Code updated:

transaction{
obj = deserializeJSON(rc.fieldnames);
writeDump(obj.id);
local.dashboard = dashboardService.get(1);
local.dashboard.setName(“Test”);
local.dashboard.setLayout(“test”);
local.dashboard.setUpdated_at(Now());
populateModel(model=local.dashboard, exclude=“id”);
dashboardService.save(local.dashboard);
}
}

event.renderData(data=local.dashboard, type=“json”);

Code updated, same error…

Where does it fail?

On this line: event.renderData(data=local.dashboard, type=“json”);

What are your scope settings set to in the Railo admin? I’m guess this is most likely a Railo issue. Have you tried posted on that list? What version of Railo are you using?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

I’ve posted on railo list, no answer till now.

About my scope settings are the default ones.

Railo version 4.0.4.001

Here is my full stacktrace:

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

Error Messages: key [DASHBOARD] doesn’t exist in struct (keys:)

Tag Context:
ID: ??
LINE: 96
Template: E:\wamp\www\angular\handlers\api\Dashboards.cfc
ID: ??
LINE: 756
Template: E:\wamp\www\angular\coldbox\system\web\Controller.cfc
ID: ??
LINE: 640
Template: E:\wamp\www\angular\coldbox\system\web\Controller.cfc
ID: ??
LINE: 236
Template: E:\wamp\www\angular\coldbox\system\Coldbox.cfc
ID: ??
LINE: 62
Template: E:\wamp\www\angular\Application.cfc
Framework Snapshot
Current Event: api.dashboards.update
Current Layout: N/A (Module: )
Current View: N/A
Bug Date: 05/31/2013 04:14:14 AM
Coldfusion ID: CFID=9f1a02f0-59d7-476b-a3cf-a6023762ae68 ; CFToken=0 ; JSessionID=CFE303D8765B4296880EF22ABBBF227C_9f1a02f0-59d7-476b-a3cf-a6023762ae68_0
Template Path : E:\wamp\www\angular\index.cfm
Path Info : /api/dashboards/1
Host & Server: www.angular.test:8888 Francesco-PC
Query String:
Browser: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36
Remote Address: 127.0.0.1
Form variables:
{ created_at: “May, 31 2013 03:37:34 0200”, id: 1, layout: “test”, locked: false, name: “TEST”, time: “May, 31 2013 03:37:34 0200”, updated_at: “May, 31 2013 03:43:50 0200”, widgets: [] }:
Session Storage:
Cookies:
coldbox_debugmode_e3ec56d0d3d86ce25fbdfe6f0fd4bb70: true
railo_admin_lastpage: services.datasource
cftoken: 0
railo_admin_lang: en
jsessionid: 323910D1E521053F8B07423A2F11FE6C
__ngdebug: true
cfid: 9f1a02f0-59d7-476b-a3cf-a6023762ae68
Stack Trace:

key [DASHBOARD] doesn't exist in struct (keys:)
	at railo.runtime.type.util.StructSupport.invalidKey(StructSupport.java:33):33
	at railo.runtime.type.StructImpl.get(StructImpl.java:77):77
	at railo.runtime.type.util.StructSupport.get(StructSupport.java:217):217
	at railo.runtime.util.VariableUtilImpl.get(VariableUtilImpl.java:243):243
	at railo.runtime.PageContextImpl.get(PageContextImpl.java:1343):1343
	at handlers.api.dashboards_cfc$cf.udfCall(E:\wamp\www\angular\handlers\api\Dashboards.cfc:96):96
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:275):275
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:608):608
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490
	at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1796):1796
	at railo.runtime.tag.Invoke.doComponent(Invoke.java:209):209
	at railo.runtime.tag.Invoke.doEndTag(Invoke.java:182):182
	at coldbox.system.web.controller_cfc$cf._6(E:\wamp\www\angular\coldbox\system\web\Controller.cfc:756):756
	at coldbox.system.web.controller_cfc$cf.udfCall(E:\wamp\www\angular\coldbox\system\web\Controller.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284
	at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:775):775
	at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723
	at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1506):1506
	at coldbox.system.web.controller_cfc$cf._5(E:\wamp\www\angular\coldbox\system\web\Controller.cfc:640):640
	at coldbox.system.web.controller_cfc$cf.udfCall(E:\wamp\www\angular\coldbox\system\web\Controller.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:275):275
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:608):608
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490
	at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1800):1800
	at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:749):749
	at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1521):1521
	at coldbox.system.coldbox_cfc$cf._1(E:\wamp\www\angular\coldbox\system\Coldbox.cfc:236):236
	at coldbox.system.coldbox_cfc$cf.udfCall(E:\wamp\www\angular\coldbox\system\Coldbox.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284
	at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:775):775
	at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723
	at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1506):1506
	at application_cfc$cf.udfCall(E:\wamp\www\angular\Application.cfc:62):62
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:607):607
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490
	at railo.runtime.ComponentImpl.call(ComponentImpl.java:1781):1781
	at railo.runtime.listener.ModernAppListener.call(ModernAppListener.java:346):346
	at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:107):107
	at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:18):18
	at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2255):2255
	at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2222):2222
	at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:315):315
	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.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749):749
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487):487
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412):412
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339):339
	at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213):213
	at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171):171
	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:394):394
	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:472):472
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171):171
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99):99
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407):407
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004):1004
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589):589
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312):312
	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 is an interesting behavior Can you fairly consistently re-create the error?

Try wrapping the whole block in a try catch, and E-mail yourself the contents of the local scope when the error happens. Also, there any chance that there is a struct called “local” in your form, URL, or variables scope? (or anywhere Railo might search)

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

Thanks for your help, Brad.

I’ve made some test: I have wrapped the code in try/catch and email the local scope. It seems that the error is generated only at this line of code:

event.renderData(data=local.dashboard, type="json");

I think that for some reason sometimes happen that after the orm object is created and updated in the database, then it will be deleted from the local scope. I think this because if the object is not created on local.dashboard = dashboardService.get(1); I should get an error at the next line: local.dashboard.setName(“TEST”);

But the error was fired only when it try to render the event…

This sould be a railo bug or probably a wrong installation on my local machine.

That is interesting. It makes sense that local.dashboard would be NULL if the get didn’t find a record. It does not make sense why it would wait to error until later in page. I’m curious of the transaction affects the behavior since that is when the ORM session is flushed.

I would continue to follow up with this on the Railo list to get more information.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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