Cause of 'tmpFile.renameTo(classFile) failed' during JSP compilation

Miro A. picture Miro A. · Sep 10, 2010 · Viewed 11k times · Source

Recently, I started to experience strange behaviour in JBOss 4.0.5 JSP application. The JSP compilation fails on first (second, third,..) attempt with exception:

17:24:29,909 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.io.IOException: tmpFile.renameTo(classFile) failed
        at org.apache.jasper.compiler.SmapUtil$SDEInstaller.install(SmapUtil.java:245)
        at org.apache.jasper.compiler.SmapUtil.installSmap(SmapUtil.java:164)
        at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:429)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

After few retries (where few is 0 to ~ 7), the page gets eventually compiled and renders OK.

Platform is Windows 7-Pro 64 bit, Java version is

c:\ATG\ATG2007.1>java -version
java version "1.5.0_21"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_21-b01)
Java HotSpot(TM) Client VM (build 1.5.0_21-b01, mixed mode)

JBoss version:

16:49:51,384 INFO  [Server] Release ID: JBoss [Zion] 4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)

Tomcat version is 5.5 (the one included with JBoss).

Thanks.

Answer

John Fitzpatrick picture John Fitzpatrick · Aug 8, 2014

Fast forward four years to 2014. Tomcat 8, Java 8, Windows 8, same error. After half a day of frustration it turns out to be caused by my antivirus software, which in my case was McAfee. I went extreme and uninstalled the whole thing. But there was probably some setting I could have made to exclude the Tomcat directories from live scanning.