我用tomcat7-maven-plugin:exec-war-only
. 插件配置如下所示:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<warFile>${project.build.outputDirectory}/${project.build.finalName}.war</warFile>
<mode>both</mode>
<enableNaming>true</enableNaming>
</configuration>
<executions>
<execution>
<goals>
<goal>exec-war-only</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
然后tomcat7:run-war
部署应用程序,它运行得很好。如果我运行mvn package
应用程序 jar 将被创建。如果我再运行java -jar app.jar
它,它将成功地部署在 Tomcat 7.0.37 中。但是它不能编译任何JSP。它说:
2013-09-21 00:38:05 JstlView [DEBUG] Forwarding to resource [/jsp/login.jsp] in InternalResourceView 'login'
Sep 21, 2013 12:38:05 AM org.apache.jasper.compiler.TldLocationsCache tldScanJar
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Sep 21, 2013 12:38:05 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalArgumentException: Negative time
at java.io.File.setLastModified(Unknown Source)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:376)
如您所见,JSP 名称中没有空格或特殊字符。我还尝试将 app.jar 放在驱动器的根目录中,以排除文件夹名称中任何可能的字符。效果是一样的。
UPD。我使用远程调试来查看会发生什么。并且线路Long jspLastModified = ctxt.getLastModified(ctxt.getJspFile());
返回-1
。在它ctxt.getJspFile()
返回"/jsp/login.jsp"
。