Pivotal Knowledge Base

Follow

Upgrade to Tomcat 7.0.57 and 8.0.15 or Later may Cause JSP Compilation Error "HTTP Status 500 - Unable to compile class for JSP" on JSP Page

Environment

Product Version
ASF Tomcat 7.0.57 and later
ASF Tomcat 8.0.15 and later

 

Symptom

When upgrading Tomcat to version 7.0.57 or 8.0.15 and later, users may get the following JSP compilation error if any of JSP pages contain any invalid < %@ import="some_values;" % > directives that end with a semicolon ";".

For example, error page contains the following stack trace:

HTTP Status 500 - Unable to compile class for JSP

type Exception report

message Unable to compile class for JSP

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:672)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause

java.lang.IllegalArgumentException: Page directive: invalid value for import
org.apache.jasper.compiler.Node$PageDirective.validateImport(Node.java:628)
org.apache.jasper.compiler.Node$PageDirective.addImport(Node.java:609)
org.apache.jasper.compiler.Parser.parsePageDirective(Parser.java:343)
...

Cause

This known issue is due to Tomcat 7.0.57+ and 8.0.15+ Jasper changes to ensure semi-colons are not permitted in JSP import page directives to address another bug issue.

See this changelog for Tomcat 7.0.57 (also applied to 8.0.15) Jasper section.

Resolution

  • Users must make sure there are no ";" at the end of any import directives on the JPS pages to adhere to the changes in Tomcat 7.0.57 and 8.0.15 onwards.

Comments

Powered by Zendesk