JSP 编译器的负时间

发布于 2024-12-22 14:05:32 字数 2058 浏览 0 评论 0原文

什么可能导致这样的错误? File.java 的 Javadoc 表示,如果传入负值,它将抛出此异常。那么问题来了,为什么 jasper 传入的是负值。我寻找了 jasper 源,但没有找到与我正在运行的完全匹配的源,行号不太匹配。我的版本从 File.lastModified 设置了上次修改时间,根据 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)

...

更新:我下载了 Tomcat 的源代码并通读了源代码。 Compile.java 中的相关代码是:

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

ctxt 是一个 JspCompilationContext,如果有任何错误,它默认返回 -1,并且 File 从负参数抛出 IllegalArgumentException。我仍然不知道为什么会收到错误,至少我知道 IllegalArgumentException 是从哪里来的。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

安静 2024-12-29 14:05:33

看起来像是Tomcat 中的一个错误。尝试 Tomcat 7.0.16,其中它没有显式设置生成的 Java 文件的最后修改时间。在该版本之后它发生了变化。如果它适用于 7.0.16,我会向 Tomcat 人员报告一个错误,如下尽可能详细地了解该平台(Redhat 5 的信息不够)。

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

浪推晚风 2024-12-29 14:05:33

我面临着同样的问题。 maven 有一个错误。他们期望路径的值应该以“/”开头。
我的初始Maven配置:

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

我在路径前面添加了“/”,修改后,它看起来像这样:

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

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>
北风几吹夏 2024-12-29 14:05:32

当我从 IntelliJ Idea 部署应用程序并在应用程序上下文中添加尾部斜杠时,我在 7.0.27 中遇到了同样的问题 - 删除它对我有用

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

蓝眼睛不忧郁 2024-12-29 14:05:32

当我的 WAR 文件名称中包含空格和句点时,我收到此错误。删除它们解决了问题。

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

日暮斜阳 2024-12-29 14:05:32

如果文件或包含的文件夹包含算术字符,则会出现错误。该错误已于 7.0.27 起修复

我实际上正在运行 7.0.32,仍然遇到这个问题,但由于我注意到它存在算术字符问题,我想我会测试一个理论。果然,我的问题的原因是因为包含的文件夹名称包含空格字符。我删除了文件夹名称中的空格,它工作正常。到目前为止,我还没有深入研究是否有关于该空间的新错误报告,但我会检查一下,如果没有,我会提交一个新错误。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文