在本地生成.war文件之后上传到服务器的tomcat webapps目录下,tomcat会自动把.war文件解压并生成一个web应用。访问时却出现这样的错误。
org.apache.jasper.JasperException: java.lang.IllegalStateException: No output folder
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:538)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
root cause
java.lang.IllegalStateException: No output folder
org.apache.jasper.JspCompilationContext.createOutputDir(JspCompilationContext.java:678)
org.apache.jasper.JspCompilationContext.getOutputDir(JspCompilationContext.java:197)
org.apache.jasper.JspCompilationContext.getClassFileName(JspCompilationContext.java:514)
org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:453)
org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:399)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
问题原因是,当访问tomcat这个应用时,它需要用jsp来展示内容,而jsp渲染需要work/Catalina/localhost/…. 这个文件夹里面的自动生成的类,如果tomcat的权限不够或者没有这个目录就会报错。
解决方法是,如果没有这个目录就手动建立一个(一般情况下tomcat会自动生成这个目录),还有要注意.war文件的拥有者最好和tomcat程序的拥有者保持一致!
参考这里。