Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Negative time from JSP compiler

What might be causing an error like this? Javadoc for File.java says it will throw this exception if passed in a negative value. So the question is, why is jasper passing in a negative value. I looked for the jasper sources, but I didn't find ones that match exactly what I am running, the line numbers don't quite match up. The version I have sets the last modified time from File.lastModified, which should never return a negative value, according to the javadoc.

SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalArgumentException: Negative time
        at java.io.File.setLastModified(File.java:1258)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:376)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)

...

UPDATE: I downloaded the sources for Tomcat and read through the sources. The relevant code from Compile.java is:

375   File javaFile = new File(ctxt.getServletJavaFileName());
376   Long jspLastModified = ctxt.getLastModified(ctxt.getJspFile());
377   javaFile.setLastModified(jspLastModified.longValue());

ctxt is a JspCompilationContext, which helpfully returns -1 by default if there are any errors, and File throws IllegalArgumentException from a negative argument. I still don't know why I'm getting an error, at least I know where the IllegalArgumentException is coming from.

like image 303
mmorrisson Avatar asked Dec 21 '11 00:12

mmorrisson


2 Answers

I had the same problem with 7.0.27 when I was deploying applications from IntelliJ Idea with a trailing slash in application context - removing it worked for me

like image 98
bedrin Avatar answered Sep 28 '22 02:09

bedrin


I was getting this error when my WAR file had spaces and periods in its name. Removing them fixed the issue.

like image 35
winchella Avatar answered Sep 28 '22 00:09

winchella