Skip to main content
May 27, 2016
Answered

The local variable application cannot be declared outside of a function.

  • May 27, 2016
  • 2 replies
  • 5293 views

I was receiving an ORA-936 on an application I support (Oracle 11g, CF 11, Windows Server 2012).  The database went down yesterday, for a reason unknown to me, and when it came up, I am now getting this error message.  The only pointer to the .cfm file is the referrer.  I don't see how to fix this one.  What information can I include that will help you help me?  It seems like the more I learn, something new always comes up.   Here's the error page that was displayed.  I have not changed any declarations, that I know of.   Thank you.

The local variable application cannot be declared outside of a function.

All variables defined with the var keyword must be declared inside a function.

Resources:

    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/5.0 (Windows NT 6.1; Win64; x64; rv:46.0) Gecko/20100101 Firefox/46.0

Remote Address       108.44.188.221

Referrer       https://TestServer/secure/Requirement/requirementsum.cfm?frompage=orig&CFID=58847&CFTOKEN=1c45276fd65debf-7F25B5E6-AA99-1268-0B24AB3E54D73594

Date/Time       27-May-16 01:25 PM

Stack Trace

coldfusion.compiler.ASTvariableDefinition$InvalidVarDefinition: The local variable application cannot be declared outside of a function.

    at coldfusion.compiler.ASTvariableDefinition.register(ASTvariableDefinition.java:98)

    at coldfusion.compiler.SemanticAnalyzer.transform(SemanticAnalyzer.java:340)

    at coldfusion.compiler.Treewalker.postorder(Treewalker.java:100)

    at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27)

    at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27)

    at coldfusion.compiler.NeoTranslator.parseAndTransform(NeoTranslator.java:443)

    at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:370)

    at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:147)

    at coldfusion.runtime.TemplateClassLoader$TemplateCache$1.fetch(TemplateClassLoader.java:436)

    at coldfusion.util.LruCache.get(LruCache.java:180)

    at coldfusion.runtime.TemplateClassLoader$TemplateCache.fetchSerial(TemplateClassLoader.java:362)

    at coldfusion.util.AbstractCache.fetch(AbstractCache.java:58)

    at coldfusion.util.SoftCache.get_statsOff(SoftCache.java:133)

    at coldfusion.util.SoftCache.get(SoftCache.java:81)

    at coldfusion.runtime.TemplateClassLoader.findClass(TemplateClassLoader.java:609)

    at coldfusion.filter.PathFilter.invoke(PathFilter.java:101)

    at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94)

    at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:79)

    at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)

    at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)

    at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:58)

    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:303)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    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:241)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:437)

    at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:197)

    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)

    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Thread.java:722)

This topic has been closed for replies.
Correct answer

Most likely what is happening is that something is breaking within the onError() function, which ends the process before the closing </cffunction> tag is processed.  It might make things a bit confusing, but you could put a CFTRY/CFCATCH in there to email a CFDUMP of the CFCATCH and display a generic error message.  Just remember that all code must be placed after any CFARGUMENT tags.

HTH,

^_^


I had added end marks to all the <cfset tags in the Application.cfc (<cfset ..... />  and it cleared up.  Weird.

So that brings me to another question.  When do you do the end tag like that or use the </cfset> tag?

2 replies

Legend
June 8, 2016

"var application" is not the only possible "local" reference, "local.application" does the same.

Dave Ferguson
Participating Frequently
May 27, 2016

Look for a variable outside a function that has the var keyword in front of it.  It may be in an included file or custom tag that is being called by requirementsum.cfm if you don't find it in there.

HTH,

--Dave

June 2, 2016

I've gone through the CF code numerous times; both the requirementssum.cfm and another .cfm file it includes and don't see anything in CF like that.  However, there is a bunch of Java/Javascript embedded and it has numerous var assignments.

Is there a way I can narrow the error down?   If I didn't mention it earlier, I'm an Oracle DBA and had the CF stuff thrust upon me.   I'm sure it's much simpler than it seems.

WolfShade
Legend
June 24, 2016

I had added end marks to all the <cfset tags in the Application.cfc (<cfset ..... />  and it cleared up.  Weird.

So that brings me to another question.  When do you do the end tag like that or use the </cfset> tag?


<cfset /> doesn't have an end tag.  Kind of like "The Highlander", there can be only one. 

<cfset variables.varName = "Some Value" /> or <cfset variables.varName = "Some Value"> are both correct, really.  But there is no body for cfset, so <cfset variables.varName = "Some Value"></cfset> is incorrect and will not work.

Now.. there is CFCONTENT, if you will, which _does_ have a body, and does essentially the same thing as <cfset>, but it's really for setting more than just a line of value - you can format a page and fill it with all kinds of data, and save it to a variable.

<cfcontent name="variables.varName">

<table>

  <tr>   

    <td>Column One Row One</td>

    <td>Column Two Row One</td>

  </tr>

  <tr>

    <td>Column One Row Two</td>

    <td>Column Two Row Two</td>

  </tr>

</table>

</cfcontent>

HTH,

^_^

UPDATE:  I just noticed that your onError() has CFCONTENT in it, and it's used exactly as I just described.. so.. n/m. LOL