Skip to main content
Known Participant
September 14, 2006
Question

CF looking at arrays as a struct and throwing errors

  • September 14, 2006
  • 17 replies
  • 2416 views
I am getting the following error:

Object of type class coldfusion.runtime.Struct cannot be used as an array

This occured a coupleof days ago for the foirst itme. I restarted the CF service and that fixed it. It happened again today and niether restarting hte service nor rebooting hte server has solved the problem. The arrays are definitely getting declared as arrays and we are not using structs or and struct related functions onthe site. Any insight on this would be greatly appreciated. Here is the full error with stack trace. Thanks in advance

Eric


Object of type class coldfusion.runtime.Struct cannot be used as an array


The error occurred in D:\iremroot\sechome.cfm: line 25

23 : <cflock scope="Session" timeout="10" type="Exclusive">
24 :
25 : <cfif isDefined("Session.navArray") AND ArrayLen(Session.navArray) GTE 17>
26 : <cfset SECTION_ID="#Session.navArray[3]#">
27 : <cfset sContentInsert_1="#Session.navArray[4]#">



--------------------------------------------------------------------------------

Please try the following:
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.


Browser Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)
Remote Address 30.30.3.61
Referrer https://secure.irem.purplemonkey.net//home.cfm
Date/Time 14-Sep-06 04:46 PM

Stack Trace (click to expand)
at cfsechome2ecfm642595352.runPage(D:\iremroot\sechome.cfm:25)


coldfusion.runtime.NonArrayException: Object of type class coldfusion.runtime.Struct cannot be used as an array
at coldfusion.runtime.Cast._List(Cast.java:956)
at coldfusion.runtime.CFPage.ArrayLen(CFPage.java:347)
at cfsechome2ecfm642595352.runPage(D:\iremroot\sechome.cfm:25)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:147)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:357)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:62)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:107)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:43)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:80)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:47)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:35)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:43)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.CfmServlet.service(CfmServlet.java:105)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:304)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at jrun.servlet.FilterChain.service(FilterChain.java:101)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:192)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)




    This topic has been closed for replies.

    17 replies

    Known Participant
    September 15, 2006
    yes it is declared...but has nothing to do with this issue...while section_id is a number, it is not used as part of a calculation, so whether it is a string or a number is irrelevant.

    Eric
    September 15, 2006
    Is SECTION_ID declared or used somewhere prior to this error being thrown? The name of this variable would lead me to believe it is a numeric field. I find the assignment <cfset SECTION_ID="#Session.navArray[3]#"> a bit peculiar. Do you really want a string of the contents of navArray[3]? Would <cfset SECTION_ID=Session.navArray[3]> give you what you want?
    Known Participant
    September 15, 2006
    here is the culprit...

    <CFAPPLICATION NAME="IREMSite" CLIENTMANAGEMENT="YES" SESSIONMANAGEMENT="YES" SETCLIENTCOOKIES="yes">

    Any ideas as to why this turns session arrays into structs?
    Known Participant
    September 15, 2006
    At the declaration...it is an array. This code was working fine and sometime yesterday afternoon, something happend to cause this error. Nowhere in the code is it declared as a struct. The only time session.navarray is used without array notion on it (session.navarray) is in isDefined statements. This also happened earlier in the week. Resetting CF solved the problem until it popped up yesterday. Niether resetting CF or rebooting the server solved it this time.

    Eric
    Inspiring
    September 15, 2006
    For debugging purposes, change your decision logic to this:

    <cfif isDefined("Session.navArray")>
    <cfif isArray(Session.navArray)>
    <!--- stuff you do now --->
    <cfelse>
    <cfdump var="#Session.navArray#">
    <cfabort>
    </cfif>
    <!--- etc --->
    </cfif>

    Dumping out the "array" might give you a hint as to how it's been turned
    into a struct. I seriously doubt it's CF that's getting confused here.

    --
    Adam
    Known Participant
    September 15, 2006
    <cfset session.navarray=ArrayNew(1)>
    <cfloop index="x" from="1" to="19" step="1">
    <cfset session.navarray[#x#]="">
    </cfloop>
    September 14, 2006
    Show us the code that creates navArray.