Cached class files throwing error when overwriting/updating source files

Over the weekend I uploaded a bunch of changes to my old CF site via FTP and the main index.cfm (but no other files) started throwing an error. It was very disconcerting because I couldn’t get rid of it by clearing template caches, restarting Lucee (from Windows or the admin), or even rebooting the server. I tried clearing all of the caches from the admin at the server and site level as well as setting “Inspect Templates” to “Always ( Bad )”.

Eventually, I moved the “site directory” from the website_directory/WEB-INF/lucee/cfclasses directory, causing it to be re-created, and then everything just worked. I just wanted to report this because I don’t think this should happen. Is there a best practice for deploying updates? Should I stop my server? I’ve never had to in the past and never run into this.

Windows Server 2019 (10.0) 64bit
Apache 2.4.57
Lucee 5.4.3.2
Apache Tomcat/9.0.78

Lucee 5.4.3.2 Error (java.io.FileNotFoundException)
Message C:\websites[mysite]\website\WEB-INF\lucee\cfclasses\CFC__websites_[mysite]_website7287\index_cfm$cf.class (Access is denied)

Lucee 5.4.3.2 Error (java.io.FileNotFoundException)
Message C:\websites[mysite]\website\WEB-INF\lucee\cfclasses\CFC__websites_[mysite]website7287\index_cfm$cf.class (Access is denied)
Java Stacktrace lucee.runtime.exp.NativeException: C:\websites[mysite]\website\WEB-INF\lucee\cfclasses\CFC__websites
[mysite]_website7287\index_cfm$cf.class (Access is denied)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(Unknown Source)
at java.base/java.io.FileOutputStream.(Unknown Source)
at lucee.commons.io.res.type.file.FileResource.getOutputStream(FileResource.java:264)
at lucee.commons.io.res.type.file.FileResource.getOutputStream(FileResource.java:254)
at lucee.commons.io.IOUtil.copy(IOUtil.java:171)
at lucee.runtime.compiler.CFMLCompilerImpl._compile(CFMLCompilerImpl.java:154)
at lucee.runtime.compiler.CFMLCompilerImpl.compile(CFMLCompilerImpl.java:76)
at lucee.runtime.PageSourceImpl._compile(PageSourceImpl.java:446)
at lucee.runtime.PageSourceImpl.compile(PageSourceImpl.java:413)
at lucee.runtime.PageSourceImpl.loadPhysical(PageSourceImpl.java:331)
at lucee.runtime.PageSourceImpl.loadPageThrowTemplateException(PageSourceImpl.java:237)
at lucee.runtime.PageSourceImpl.loadPage(PageSourceImpl.java:1024)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1051)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:948)
at lucee.runtime.listener.ClassicAppListener._onRequest(ClassicAppListener.java:65)
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:45)
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2493)
at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2478)
at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2449)
at lucee.runtime.engine.Request.exe(Request.java:45)
at lucee.runtime.engine.CFMLEngineImpl.service(CFMLEngineImpl.java:1216)
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1162)
at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:422)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\websites[mysite]\website\WEB-INF\lucee\cfclasses\CFC__websites
[mysite]_website7287\index_cfm$cf.class (Access is denied)
… 47 more

Timestamp 9/9/23 3:21:11 PM EDT

The hint is in the error:
Lucee 5.4.3.2 Error (java.io.FileNotFoundException)
Message C:\websites[mysite]\website\WEB-INF\lucee\cfclasses\CFC__websites_[mysite]website7287\index_cfm$cf.class (Access is denied)

Looks like for some reason lucee can’t overwrite the file because of permissions. Check what user lucee is running under and the permissions you have in the WEB-INF folder.

Yeah, but it’s not “just” a permissions issue because all the other files updated just fine. I could navigate directly to interior pages that were updated and they worked. It seems like an intermittent issue related to file locking. What role/permissions are expected?

you’ve gone and enabled check the file very time and you are updating the files on a server under load

if anything, firstly revert to once, always is never a good idea.

I’d suggest as long as your going to try and deploy to a live server, rather than going full modern blue/green deploying, is actually switching to never, as all prod server ought to be, and then calling inspectTemplates() within your application (alas inspectTemplates in 5.x is per application) after you ftp the changed files up, to tell Lucee to flag all the templates as possibly dirty and to check for modifications.

The access denied is probably coz your ftp client has locked the file to update it

Oh, I don’t think I am clear on how this works, and need to read up. But if I switched to “never” and this prevented the file locking issue, I should be able to manually clear the template cache in Lucee admin to refresh them as well, right?

alas no, as because as I mentioned, that function alas only works for per application

inspectTemplates() is super light weight which just checks for changes once, the alternative is pagePoolClear() which blows away the whole cache

I’m only updating 1 application at a time, so not sure why this would matter if I’m doing it within that apps’ admin interface (I wasn’t clear on that). I appreciate your reply and insight, just trying to get my head around the details. I’ll check out inspectTemplates and how I can leverage that.

I updated “Inspect Templates” to “never” and dropped a trigger for InspectTemplates() into my admin area and it works like a charm! Thanks for the info.

2 Likes

great! thanks for reporting back!