Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
810 views
in Technique[技术] by (71.8m points)

tomcat - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...