Negative time from JSP compiler
Asked Answered
P

5

8

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.

Phytogeography answered 21/12, 2011 at 0:46 Comment(5)
What Tomcat version? What platform make/version/architecture? What JDK make/version?Glowing
Tomcat 7, JDK 6, platform is Redhat 5Phytogeography
Be more specific in versions please. There are currently 23 different Tomcat 7 versions with latest being 7.0.23, for example.Glowing
TC 7.0.23, JDK 1.6.0-29 64bitPhytogeography
Downloaded the source for 7.0.23 and I have the jasper Compiler.java. Digging through it now to figure out where it gets last modified from.Phytogeography
S
5

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

Sumption answered 28/5, 2015 at 15:35 Comment(1)
Ran into the same problem in Intellij 2016.1. After removing the trailing slash in the application context in the Tomcat config it works again. Thanks.Ctenophore
S
4

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

Sowell answered 24/10, 2012 at 16:53 Comment(1)
Had problems even when WAR file had a hyphen '-'Seismic
A
3

There is a bug if the file or the containing folder contains arithmetic characters. The bug has since been fixed as of 7.0.27.

I am actually running 7.0.32 and still encountered this issue but since I noticed it had issues with arithmetic characters I though I'd test a theory. Sure enough, the reason for my problem was because the containing folder name contained a space character. I removed the space in the folder name and it works fine. I haven't looked to in depth as of yet to find out if there is a new bug reported concerning the space but I will check it out and submit a new one if not.

Agonize answered 18/10, 2012 at 15:51 Comment(0)
G
0

Look like a bug in Tomcat. Try Tomcat 7.0.16, therein it doesn't explicitly set the last modified on the generated Java file. After that version it was changed. If it works with 7.0.16, I'd report a bug to Tomcat guys with as much as possible detail about the platform (Redhat 5 is not enough information).

Glowing answered 21/12, 2011 at 1:9 Comment(0)
N
0

I was facing the same issue. There is a bug with maven. They expect value of path should start with '/'. My Initial Maven Config:

<plugin>
       <groupId>org.apache.tomcat.maven</groupId>
       <artifactId>tomcat7-maven-plugin</artifactId>
       <version>2.2</version>
       <configuration>
            <path>TimeToBookUber</path>
       </configuration>
</plugin>

I added '/' in front of the path and after modification, it looks like this:

<plugin>
       <groupId>org.apache.tomcat.maven</groupId>
       <artifactId>tomcat7-maven-plugin</artifactId>
       <version>2.2</version>
       <configuration>
            <path>/TimeToBookUber</path>
       </configuration>
</plugin>
Numbat answered 28/12, 2019 at 11:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.