Application Variables being lost

I’m starting to see some errors that haven’t appeared before. I -think- it’s since I applied the 5.1.3.18 update

I have some code that writes to a text file and is called through

<cfset application.MessageWriter.statusMSG(session.orderType,"Created Article")>

This is part of a long running process and I use it to write to a status window so users can see where things are at.

It will be running along fine and then it will fail with the message that the application variable doesn’t exist.

;key [MESSAGEWRITER] doesn't exist;lucee.runtime.exp.ExpressionException: key [MESSAGEWRITER] doesn't exist

The application doesn’t seem to have hit its timeout which is about the only reason I could think of to lose the variable.

When this first started happening, I thought it might be a file lock issue on the text file and the message was just Lucee being confused but I’m now seeing it in another variable

key [JAVABOT] doesn't exist;lucee.runtime.exp.ExpressionException: key [JAVABOT] doesn't exist

which is a call to some java that does GETs and POSTs.

When these error, my process aborts and has to be restarted…and the variables are fine again. (without resetting the application)

Any idea what could be going on?

1 Like

I have experienced something like this in a CFWheels application we were trying to run in Lucee. I cannot seem to narrow down what is timing out. It will throw an error and then, like you stated, be fine again. Really frustrated and this is mostly due to my inability to narrow down a reliable cause and research a solution. Your post just stuck out to me today and I thought I would chime in.

Aaron

Currently Running:

Performance/Language
Inspect Templates (CFM/CFC) Once ( Good )
Null Support Partial Support (CFML Default)
Key case Convert to upper case (CFML Default)
Local scope mode Classic (CFML Default)
General Info
Version Lucee 5.2.2.71-RC
Version Name Velvet
Release date Jul 25, 2017
ColdFusion® compatibility version 2016.0.03.300357
Configuration File /Library/Lucee/config/server/lucee-server/context/lucee-server.xml
OS Mac OS X (10.12.6) 64bit
Remote IP 0:0:0:0:0:0:0:1
Host Name localhost
Servlet Container Apache Tomcat/8.5.16
Java 1.8.0_144 (Oracle Corporation) 64bit
Architecture 64bit

Lucee 5.2.2.71-RC Error (expression)
Message The key [APPLICATIONNAME] does not exist, only the following keys are available: [$WHEELS].
Stacktrace The Error Occurred in
/Users/PATHTOAPPLICATION/wheels/events/onerror.cfm: line 16
14:
15: $initializeRequestScope();
16: local.lockName = “reloadLock” & application.applicationName;
17: local.rv = $simpleLock(name=local.lockName, execute=“$runOnError”, executeArgs=arguments, type=“readOnly”, timeout=360);
18: writeOutput(local.rv);

Java Stacktrace lucee.runtime.exp.ExpressionException: The key [APPLICATIONNAME] does not exist, only the following keys are available: [$WHEELS].
at lucee.runtime.type.util.StructSupport.invalidKey(StructSupport.java:66)
at lucee.runtime.type.StructImpl.get(StructImpl.java:135)
at wheels.events.onerror_cfm$cf.udfCall(/wheels/events/onerror.cfm:16)
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:107)
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:355)
at lucee.runtime.type.UDFImpl.call(UDFImpl.java:226)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:662)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:580)
at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1918)
at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:420)
at lucee.runtime.listener.ModernAppListener.onError(ModernAppListener.java:407)
at lucee.runtime.listener.MixedAppListener.onError(MixedAppListener.java:131)
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2416)
at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2390)
at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2358)
at lucee.runtime.engine.Request.exe(Request.java:46)
at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1044)
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:992)
at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:102)
at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:486)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

Timestamp 8/7/17 2:20:14 PM PDT

I know this is a very old issue but if anybody sees this and can give a hint about what could be causing application. variables set during onApplicationStart just going away (being undefined) during long processes, I am hitting a wall and could use all the help I can get!

In my case, it seems this behavior was related to the application.applicationTimeout setting which defaults to 1 day, at which point all the application variables in my long running (more than 24 hours) thread gets wiped out, causing errors

And so you’ve solved it by raising the timeout, then? Or are you still seeking further discussion.

I’ll say that I’d not myself had or seen a request lasting longer than the app timeout timespan. I suspect some might presume that “a running request should keep the application alive”, but I suspect the tracking of “this request’s” contributing to “the app being alive” is done only either at the start or end of the request.

That would then explain that if NO OTHER REQUESTS are running and contributing to “keeping the app alive”, the app scope could timeout while this one really long-running request continues.

Not saying I KNOW what’s going on. (And I realize any of us could “look at the lucee source”. I’m on my phone and that’s a bit fiddly.) Just thought it was an interesting topic and so contributing to the discussion, assuming you may have been seeking more thoughts. If you’re OK to leave it at you’ve raised the timeout, no worries.

Thanks for your response, yes for now I’ve just raised the timeout. This is for a legacy job that doesn’t receive any other requests than the initial request that kicks off a background thread which can stay active for days. It was migrated out of an app that did receive other requests so its not a huge surprise this started happening now that it is standalone.

Ok, sir. :slight_smile: