tracker issue : CF-3971871

select a category, or use search below
(searches all categories and all time range)

java.lang.ClassCastException when looping over query and returning a structure in a try block

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Bryan Henderson / Bryan Henderson (Bryan Henderson)

Created: 04/17/2015

Components: Language, CF Component

Versions: 11.0

Failure Type: Crash

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Normal / All users will encounter

Locale/System: ALL / Windows 7 64-bit

Vote Count: 2

Listed in the version 2016.0.03.300466 Issues Fixed doc
Problem Description:

A component defined as follows:
	<cffunction name="foo">
			<cfloop query="#QueryNew('one')#">
				<cfreturn bar(a={b = 0}) />

will cause a java.lang.ClassCastException when instantiated with createObject function or cfobject tag.

Steps to Reproduce:
create a component as defined above named "test.cfc".
in another file, instantiate an instance of the test component:
<cfobject component="test" name="test" />

Actual Result:
runtime exception:
  Message = "",
  StackTrace = "java.lang.ClassCastException",
  Suppressed = [],
  TagContext = [],
  Type = "java.lang.ClassCastException"

Expected Result:

continued program execution

Any Workarounds:

Do not use a try block
do not pass a structure the the function in the cfreturn tag
use cfoutput instead of cfquery

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3971871

External Customer Info:
External Company:  
External Customer Name: Bryan
External Customer Email:  
External Test Config: My Hardware and Environment details:

CF 11,0,05,293506 on Windows 7 running on Dell Precision M6700



under workarounds, the third option should read: use cfoutput instead of cfloop
Comment by External U.
7778 | April 17, 2015 12:12:58 PM GMT
the error above occurs on the second and subsequent executions. the first time this error occurs it is more detailed: message = coldfusion.compiler.ASTcfloop cannot be cast to coldfusion.compiler.ASTcftag StackTrace = java.lang.ClassCastException: coldfusion.compiler.ASTcfloop cannot be cast to coldfusion.compiler.ASTcftag at coldfusion.compiler.SemanticAnalyzer.preTransform( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.NeoTranslator.parseAndTransform( at coldfusion.compiler.NeoTranslator.translateJava( at coldfusion.compiler.NeoTranslator.translateJava( at coldfusion.runtime.TemplateClassLoader$TemplateCache$1.fetch( at coldfusion.util.LruCache.get( at coldfusion.runtime.TemplateClassLoader$TemplateCache.fetchSerial( at coldfusion.util.AbstractCache.fetch( at coldfusion.util.SoftCache.get_statsOff( at coldfusion.util.SoftCache.get( at coldfusion.runtime.TemplateClassLoader.findClass( at coldfusion.runtime.RuntimeServiceImpl.getFile( at coldfusion.runtime.RuntimeServiceImpl.resolveTemplatePath( at coldfusion.runtime.TemplateProxyFactory.getResolvedFile( at coldfusion.runtime.TemplateProxyFactory.getTemplateFileHelper( at coldfusion.runtime.MetadataUtils.getComponentMetadata( at coldfusion.runtime.CfJspPage.GetComponentMetadata(
Comment by External U.
7779 | April 17, 2015 12:38:54 PM GMT
Attached the cfc file . Once you create an object of this cfc the above exception would be observed. Passing an inline struct to a function is the issue.
Comment by Suchika S.
7780 | April 27, 2015 05:40:46 AM GMT
very annoying bug you need to rewrite a lot if code if you used "cfloop query" often and you can't simply search/replace with "cfoutput query" because of nesting cfoutput problem
Vote by External U.
7781 | May 13, 2015 03:31:59 AM GMT
I experience this bug when I port a software running on CF 10 to CF 11. It does not simply work in the new version, though it does in the older.
Vote by External U.
7782 | November 27, 2015 04:03:17 PM GMT