Can't cast String [] to a boolean error

414 views
Skip to first unread message

Cheeky

unread,
Sep 26, 2009, 6:27:15 AM9/26/09
to Railo
Hi all

I am encountering an issue when running a piece of code in Railo that
previously worked in Coldfusion.
The error I am getting is: "Can't cast String [] to a boolean".

This occurs with the following line of code:

<cfif qDetail.RecordCount>
...
</cfif>

As you can see, I previously relied on the fact that the RecordCount
of 0 would be false and anything greater than 0 would be true. This
does not seem to be working for Railo though.

Is this a bug or deliberate functionality?

Before I go and change all my code to <cfif qDetail.RecordCount GT 0>
I just want to make sure I am not missing anything??

Thanks
Paolo

Todd Rafferty

unread,
Sep 26, 2009, 8:01:00 AM9/26/09
to ra...@googlegroups.com
No, it has to be something else causing the issue. I know people that do that all the time and I sometimes do it.

It's easy to write a testcase and check to see if something fails or not in Railo. Here's my testcase:

<cfset stuff = queryNew('id,blah')>
<cfloop index="x" from="1" to="10">
<cfset queryAddRow(stuff)>
<cfset querySetCell(stuff,'id',x)>
<cfset querySetCell(stuff,'blah','test')>
</cfloop>

<cfif stuff.recordcount>
<cfdump eval=stuff>
</cfif>

It works just fine. Now, we just need to help you track down where the error is really coming from.  Can you provide the error and stack trace please?  Thanks.

~Todd

Cheeky

unread,
Sep 26, 2009, 8:46:16 AM9/26/09
to Railo
Hi Todd.

I made the change to <cfif qDetail.RecordCount GT 0> and the error
disappeared.

But this is occurring on many pages - so here is another page where it
is occurring:
I have a public test page on my staging server that illustrates the
issue: http://www.paolobroccardo.com/cheekyonline2009/index.cfm?cheekypage=category.create

Error and Stack Trace:

Railo 3.1.0.022 Error (Expression)
Message Can't cast String [] to a boolean
Stacktrace The Error Occurred in
C:\Railo\webapps\ROOT\cheekyonline2009\_view\pages\category
\dsp_update.cfm: line 8

6:
7: <cfloop list="#attributeList#" index="cItem">
8: <cfif qDetail.RecordCount>
9: <cfparam name="attributes.#cItem#" default="#Trim(Evaluate
('qDetail.'&cItem))#" type="string">
10: <cfelse>

called fromC:\Railo\webapps\ROOT\cheekyonline2009\parsed
\category.create.cfm: line 29

27: <cfsavecontent variable="pageContent">
28: <cftry>
29: <cfoutput><cfinclude template="../_view/pages/category/
dsp_update.cfm"></cfoutput>
30: <cfcatch type="missingInclude"><cfif len
(cfcatch.MissingFileName) gte 14 and right(cfcatch.MissingFileName,14)
is "dsp_update.cfm">
31: <cfthrow type="fusebox.missingFuse" message="missing Fuse"
detail="You tried to include a fuse dsp_update.cfm in circuit
v_pages_category which does not exist (from fuseaction
v_pages_category.create).">

called fromC:\Railo\webapps\ROOT\fusebox5\Application.cfc: line 228

226: --->
227: <cflock name="#_parsedFileData.lockName#" type="readonly"
timeout="30">
228: <cfinclude template="#_parsedFileData.parsedFile#" />
229: </cflock>
230: <cfcatch type="missinginclude">

Java Stacktrace

Can't cast String [] to a boolean
at railo.runtime.op.Caster.toBooleanValue(Caster.java:303):303
at railo.runtime.op.Caster.toBooleanValue(Caster.java:279):279
at cheekyonline2009._view.pages.category.dsp_update_cfm$cf.call(C:
\Railo\webapps\ROOT\cheekyonline2009\_view\pages\category
\dsp_update.cfm:8):8
at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:638):
638
at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:591):
591
at cheekyonline2009.parsed.category_create_cfm414$cf.call(C:\Railo
\webapps\ROOT\cheekyonline2009\parsed\category.create.cfm:29):29
at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:638):
638
at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:591):
591
at fusebox5.application_cfc$cf.udfCall1(C:\Railo\webapps\ROOT
\fusebox5\Application.cfc:228):228
at fusebox5.application_cfc$cf.udfCall(C:\Railo\webapps\ROOT
\fusebox5\Application.cfc):-1
at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:166):166
at railo.runtime.type.UDFImpl._call(UDFImpl.java:319):319
at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284
at railo.runtime.ComponentImpl._call(ComponentImpl.java:400):400
at railo.runtime.ComponentImpl._call(ComponentImpl.java:332):332
at railo.runtime.ComponentImpl.call(ComponentImpl.java:1486):1486
at railo.runtime.listener.ModernAppListener.call
(ModernAppListener.java:282):282
at railo.runtime.listener.ModernAppListener._onRequest
(ModernAppListener.java:109):109
at railo.runtime.listener.MixedAppListener.onRequest
(MixedAppListener.java:23):23
at railo.runtime.PageContextImpl.execute(PageContextImpl.java:1676):
1676
at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:
248):248
at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:32):32
at javax.servlet.http.HttpServlet.service(HttpServlet.java:91):91
at com.caucho.server.dispatch.ServletFilterChain.doFilter
(ServletFilterChain.java:103):103
at com.caucho.server.webapp.WebAppFilterChain.doFilter
(WebAppFilterChain.java:175):175
at com.caucho.server.dispatch.ServletInvocation.service
(ServletInvocation.java:240):240
at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:
424):424
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:481):
481
at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:685):685
at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:607):607
at java.lang.Thread.run(Unknown Source):-1

Thanks
Paolo



Cheeky

unread,
Sep 26, 2009, 9:04:33 AM9/26/09
to Railo
Aaah - I apologize - You won't be able to see the page as it is locked
behind my admin section.
But all the info I see when the page loads is detailed above.

Thanks
Paolo

Todd Rafferty

unread,
Sep 26, 2009, 9:08:55 AM9/26/09
to ra...@googlegroups.com
What version of Railo are you running? I'm running 3.1.1.008

I hooked up to a real mysql db:

<cfquery name="test" datasource="realdb">
SELECT * from tag
</cfquery>
<cfif test.recordcount>
<cfdump eval=test>
</cfif>

It works fine.

~Todd Rafferty * Railo Community Manager -- Volunteer * http://getRailo.org/

Cheeky

unread,
Sep 26, 2009, 9:21:38 AM9/26/09
to Railo
Hi Todd

Mine shows Railo: 3.1.0.022 rc

Should I upgrade?

Thanks
Paolo

Todd Rafferty

unread,
Sep 26, 2009, 9:30:39 AM9/26/09
to ra...@googlegroups.com
3.1.1 is "final public release" - do you wan to run release candidate or final?  It's an easy upgrade. Just log into the server and click "Update" and follow the instructions.

~Todd Rafferty * Railo Community Manager -- Volunteer * http://getRailo.org/

Cheeky

unread,
Sep 26, 2009, 9:49:16 AM9/26/09
to Railo
Hi Todd

I upgraded to the latest version to see what happened.
Funnily enough I noticed the following in the Patches / Info before I
upgraded:
[ RAILO-324 ] javacast not support arrays
This sounds a lot like the issue I was having.

But alas - the upgrade did not help. :(
A bit off topic but the new look administrator is great and I swear
things just sped up a whole lot more too?!

But back to the issue...

Ok - I have whittled it down to this little bit of code below. as you
can see, this is a create, so there is an empty qDetail query being
built.
This differes slightly from the quick examples you set up as you were
doing cfquery's to build the queries.

Do you see anything strange below? :

<cfparam name="qDetail" default="#QueryNew('RecordCount')#">
<cfparam name="attributeList" default="">

<cfset attributeList =
"categoryId,categoryName,categoryDescription,categoryStampId,categoryStampDate" /
>

<cfloop list="#attributeList#" index="cItem">
<cfif qDetail.RecordCount>
<cfparam name="attributes.#cItem#" default="#Trim(Evaluate
('qDetail.'&cItem))#" type="string">
<cfelse>
<cfparam name="attributes.#cItem#" default="" type="string">
</cfif>
</cfloop>
<cfif qDetail.RecordCount>
<cfparam name="attributes.categoryActiveYN"
default="#qDetail.categoryActiveYN#" />
<cfelse>
<cfparam name="attributes.categoryActiveYN" default="Y" />
</cfif>


Thanks
Paolo


Todd Rafferty

unread,
Sep 26, 2009, 10:08:43 AM9/26/09
to ra...@googlegroups.com
Paolo,

The whole block of code you just pasted is 'strange'. What are you doing and why?

This is wrong:
<cfparam name="qDetail" default="#QueryNew('RecordCount')#">

Change it to:
<cfparam name="qDetail" default="#QueryNew('categoryId,categoryName,categoryDescription,categoryStampId,categoryStampDate')#">

qDetail automatically gets a "recordcount" of 0 because the query object is empty. <cfdump eval=qDetail> after it and see what you get and work from there to populate the query using queryAddRow() and querySetCell() which is the safe way of populating a query of query (unless it comes from a real query ;) ).

~Todd Rafferty * Railo Community Manager -- Volunteer * http://getRailo.org/

Cheeky

unread,
Sep 26, 2009, 10:22:07 AM9/26/09
to Railo
Hi Todd

Just to explain the code.

It is a code sample for a page that gets used as a CREATE as well as
an UPDATE page.
Therefore there may or may not be a qDetail query passed to the page.

That's why I have the line:
<cfparam name="qDetail" default="#QueryNew('RecordCount')#">

This creates a new blank query with a 'RecordCount' column as no other
columns are required. True, like you said, this could be any column
name as the blank query would automatically have the RecordCount
property.

The fact remains that in Coldfusion, this code executes.

What I did now though, is I changed the name of the default column
from 'RecordCount' to 'Test', as follows:
<cfparam name="qDetail" default="#QueryNew('Test')#">

Now the code executes fine in Railo.

Obviously there must be some sort of conflict between the column name
I am giving the query and the RecordCount property of the query?!?
Do you think this is a bug that should be reported? Or do you think
Coldfusion is at fault for allowing it?

Thanks, Paolo



Todd Rafferty

unread,
Sep 26, 2009, 10:34:50 AM9/26/09
to ra...@googlegroups.com
In the end, it is up to the Railo dev team if they think this should be fixed. If you think it's a bug, post it: http://jira.jboss.org/jira/browse/RAILO

I personally think that Railo is the stricter of the two engines and quite frankly, I want to keep it that way. ColdFusion should have thrown an error. Recordcount, in terms of a query object, should be a reserved word.

~Todd Rafferty * Railo Community Manager -- Volunteer * http://getRailo.org/

Cheeky

unread,
Sep 26, 2009, 10:54:05 AM9/26/09
to Railo
Yeah Todd, I agree.

Thanks for your help!

On Sep 26, 4:34 pm, Todd Rafferty <t...@getrailo.org> wrote:
> In the end, it is up to the Railo dev team if they think this should be
> fixed. If you think it's a bug, post it:http://jira.jboss.org/jira/browse/RAILO
>
> I personally think that Railo is the stricter of the two engines and quite
> frankly, I want to keep it that way. ColdFusion should have thrown an error.
> Recordcount, in terms of a query object, should be a reserved word.
>
> ~Todd Rafferty * Railo Community Manager -- Volunteer *http://getRailo.org/

Sean Corfield

unread,
Sep 26, 2009, 3:24:46 PM9/26/09
to ra...@googlegroups.com
On Sat, Sep 26, 2009 at 6:49 AM, Cheeky <djlis...@gmail.com> wrote:
> Do you see anything strange below? :
>
> <cfparam name="qDetail" default="#QueryNew('RecordCount')#">

At this point qDetail.RecordCount is a *column* which means it's
essentially an array. The difference in behavior comes from how the
engines look up variables.

It seems that Adobe CF treats qDetails.RecordCount as the special
query object variable whereas Railo treats it as a column.

Interesting edge case. Definitely bad practice code, IMO, but it could
be argued that Railo should treat recordCount as special. It may have
performance impacts (most of Adobe CF's 'odd' behavior has performance
impacts - which is why Railo is often faster where it is stricter).
I'll open a JIRA ticket for this but Michael will need to determine
the performance impact before we make a call on whether to change the
behavior.

In the meantime, do a search & replace for querynew('recordcount') and
change them to querynew('id') or something.
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies US -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Sean Corfield

unread,
Sep 26, 2009, 3:28:47 PM9/26/09
to ra...@googlegroups.com

Cheeky

unread,
Sep 26, 2009, 3:59:57 PM9/26/09
to Railo
Hi Sean

Yeah - I actually did replace all instances to a new column name prior
to your post.
I will monitor RAILO-441 to see what the outcome is.

Regards
Paolo

Sean Corfield

unread,
Sep 27, 2009, 1:31:57 PM9/27/09
to ra...@googlegroups.com
Michael has written some test cases around this and added them to the
JIRA issue:

https://jira.jboss.org/jira/browse/RAILO-441

Based on those tests, he doesn't seem to be seeing the behavior you ran into.

Perhaps you could post a small, self-contained code fragment that
exhibits the bug into the JIRA issue as a comment?

Thanx,
Sean

Michael Offner-Streit

unread,
Sep 28, 2009, 5:10:11 AM9/28/09
to ra...@googlegroups.com
hi all

the following 2 lines already shows the problem:
<cfset qry=queryNew('recordcount')>
<cf_valueEquals left="#qry.recordcount#" right="0">

in this case adobeCF return 0 and railo "", the only addion i have in my testcases is that adobeCF only work this way for dot notation (.recordcount) and not bracket notation (['recordcount']).

in this case
<cfset qry=queryNew('recordcount')>
<cf_valueEquals left="#qry['recordcount']#" right="">
adobeCF and Railo return exact the same result.

the only question i have, make it sense that adobeCF handle dot and bracket notation not the same way

because railo use Collection.Key (http://www.getrailo.org/javadoc/railo/runtime/type/Collection.Key.html) instead of string keys for queries,
this change will not have a big impact on performance.
in a first step i search a solution that handle this at compilation time, this way we have no impact on execution at runtime.


by the way:
railo support since version 1 the following functions
<cfdump var="#queryRecordCount(qry)#">
<cfdump var="#queryColumnList(qry)#">
<cfdump var="#queryColumnArray(qry)#
because i think it is inconsistency to have a function structCount, arrayLen and no queryRecordcount.







Sean Corfield schrieb:
Reply all
Reply to author
Forward
0 new messages