[Coldfusion 10] Serious component bug

50 views
Skip to first unread message

Tom Van Schoor

unread,
Oct 25, 2012, 3:08:54 AM10/25/12
to col...@googlegroups.com
Hi Guys,

I know this is not the place for Coldfusion 10 bugs, but I thought I should give you a heads up...

Random component MyTest.cfc:

/**
* I am Test
*/
component accessors="true" {
property name="privateVarOne" default="privateVarOne default";
function init() {
return this;
}
public void function newMethod() {
var myVar = variables.privateVarOne;
writedump(var="success");
}
}

Nothing fancy right?

Call component:

<cfset test = new MyTest() />
<cfdump var="#test#" format="html">
<cfset test.newMethod() />

outputs the component followed by success; = expected behaviour.

Call component without dump:
<cfset test = new MyTest() />
<cfset test.newMethod() />

throws:

The web site you are accessing has experienced an unexpected error.
Please contact the website administrator. 


The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request

Element PRIVATEVARONE is undefined in VARIABLES.

 
The error occurred in E:/www/development/testGround/MyTest.cfc: line 13
11 : 	
12 : 	public void function newMethod() {
13 : 		var myVar = variables.privateVarOne;
14 : 		writedump(var="success");
15 : 	}

Resources:

Browser  Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
Remote Address  10.0.0.122
Referrer  
Date/Time  25-Oct-12 09:07 AM
Stack Trace
at cfMyTest2ecfc878268247$funcNEWMETHOD.runFunction(E:/www/development/testGround/MyTest.cfc:13) at cftestit2ecfm309196321.runPage(E:/www/development/testGround/testit.cfm:2) 

coldfusion.runtime.UndefinedElementException: Element PRIVATEVARONE is undefined in VARIABLES.
	at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1752)
	at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1705)
	at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1854)
	at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1833)
	at cfMyTest2ecfc878268247$funcNEWMETHOD.runFunction(E:\www\development\testGround\MyTest.cfc:13)
	at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
	at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
	at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
	at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
	at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
	at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
	at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:655)
	at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:444)
	at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:414)
	at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2432)
	at cftestit2ecfm309196321.runPage(E:\www\development\testGround\testit.cfm:2)
	at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:244)
	at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:444)
	at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
	at coldfusion.filter.IpFilter.invoke(IpFilter.java:64)
	at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:443)
	at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
	at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
	at coldfusion.filter.PathFilter.invoke(PathFilter.java:112)
	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94)
	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
	at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
	at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
	at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62)
	at coldfusion.CfmServlet.service(CfmServlet.java:219)
	at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
	at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:414)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)

--
Kind regards,
Tom Van Schoor

Andrew Scott

unread,
Oct 25, 2012, 4:28:40 AM10/25/12
to col...@googlegroups.com
I think you will find that the problem is that you are using the property name to set the variable, ColdFusion will set that into the scope this and not variables.

-- 
Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/

Tom Van Schoor

unread,
Oct 25, 2012, 5:11:06 AM10/25/12
to col...@googlegroups.com
Hi Andrew,

Nope properties go by default to the private variables scope.
The this scope is for public variables.

You can test this by initializing properties in the init function (which is by the way a work around for this problem; so not to rely on default values of properties)

The bug is that properties with a default value are not being populated into the variables struct.
You can initialize using one of three methods in the init function:

variables.privateVarOne = "privateVarOne initial variables struct";
privateVarOne = "privateVarOne initial default variables struct";
setPrivateVarOne("privateVarOne initial setter");

All three methods will set variables struct.

Here is a test you can use:

component accessors="true" {
property name="privateVarOne" type="string" default="privateVarOne default" setter="true";
property name="privateVarTwo" type="string" default="privateVarTwo default";
function init() {
var filePath = "e:\\www\development\test.html";
if(fileExists(filePath)) {
fileDelete(filePath);
}
writeDump(var="dumping this with only default values", output=filePath, format="html");
writeDump(var=this, output=filePath, format="html");

writeDump(var="dumping variables with only default values", output=filePath, format="html");
writeDump(var=variables, output=filePath, format="html");

this.onePublicVariable = "onePublicVariable initial";
/*
writeDump(var="setting privates using variables struct", output=filePath, format="html");
variables.privateVarOne = "privateVarOne initial variables struct";
variables.privateVarTwo = "privateVarTwo initial variables struct";
*/
/*
writeDump(var="setting privates using default struct", output=filePath, format="html");
privateVarOne = "privateVarOne initial default struct";
privateVarTwo = "privateVarTwo initial default struct";
*/
writeDump(var="setting privates using setters", output=filePath, format="html");
setPrivateVarOne("privateVarOne initial setter");
setPrivateVarTwo("privateVarTwo initial setter");
writeDump(var="dumping this with initial values", output=filePath, format="html");
writeDump(var=this, output=filePath, format="html");

writeDump(var="dumping variables with initial values", output=filePath, format="html");
writeDump(var=variables, output=filePath, format="html");
return this;
}
public void function newMethod() {
var myVar = variables.privateVarOne;
}
public struct function getVariables() {
return variables;
}
}

Cheers,
Tom

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
 
 

Tom Van Schoor

unread,
Oct 25, 2012, 5:13:35 AM10/25/12
to col...@googlegroups.com
And you will also see that in the init function CF does see the default values... it is in the other methods that the default value somehow magically gets lost.

Luis Majano

unread,
Oct 25, 2012, 10:44:20 AM10/25/12
to col...@googlegroups.com
I have seen this issue since cf9 where the default property does nothing on normal cfcs but works on orm entities.  Maybe you should submit this to adobe Tom!

Luis Majano
CEO
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org

Tom Van Schoor

unread,
Oct 26, 2012, 12:58:03 AM10/26/12
to col...@googlegroups.com
Hi Luis,

Did that yesterday ;)


Cheers,
Tom
Reply all
Reply to author
Forward
0 new messages