JSTL JavaScript 冲突 HTTP Status 500 – Unable to compile class for JSP

前也碰到过这样的问题,有些js写在jsp视图中,就报错,那时候没有找到原因,就直接把js放到外部文件中进行引用了。这次花了点时间去琢磨了一下。

首先申明:我这个解决方案并不适用所有出现该问题的,这只是导致该问题出现的一种原因,所以如果不适合你,请勿怪,非常感谢。

具体的报错如下:

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:677)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
	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:731)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:209)
	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:267)
	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1221)

	org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1005)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:952)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	com.renyiwei.web.filter.XssFilter.doFilter(XssFilter.java:27)
	org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)

	org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
	org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)

root cause

java.lang.ArrayIndexOutOfBoundsException
	java.lang.System.arraycopy(Native Method)
	org.gjt.xpp.impl.tokenizer.Tokenizer.next(Tokenizer.java:1274)
	org.gjt.xpp.impl.pullparser.PullParser.next(PullParser.java:392)
	org.gjt.xpp.sax2.Driver.parseSubTree(Driver.java:415)
	org.gjt.xpp.sax2.Driver.parse(Driver.java:310)
	javax.xml.parsers.SAXParser.parse(SAXParser.java:392)
	javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
	org.apache.taglibs.standard.tlv.JstlBaseTLV.validate(JstlBaseTLV.java:194)
	org.apache.taglibs.standard.tlv.JstlFmtTLV.validate(JstlFmtTLV.java:134)
	org.apache.jasper.compiler.TagLibraryInfoImpl.validate(TagLibraryInfoImpl.java:776)
	org.apache.jasper.compiler.Validator.validateXmlView(Validator.java:1882)
	org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1851)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:218)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
	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:731)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:209)
	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:267)
	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1221)

	org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1005)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:952)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)

	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	com.renyiwei.web.filter.XssFilter.doFilter(XssFilter.java:27)
	org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)

	org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)

	org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.70 logs.

Apache Tomcat/7.0.70

HTTP_Status_500_Unable_to_compile_class_for_JSP

Debug过程:

Google了很久,网上说jstl包的缘故,我也进行更换,发现没有解决问题。然后把jsp单独拿出来放一个空项目中跑,是可以的。在空项目中把所有的包放进去,会出现问题,确定是导入的包的问题。根据报错日志和对包的排查,最后发现去掉pull-parser-2.jar这个jar包之后,页面显示就正常了。

解决方案:

这个pull-parser-2.jar是被dom4j依赖的,所以我更换了该包的版本,问题得到解决。

<dependency>
 <groupId>pull-parser</groupId>
 <artifactId>pull-parser</artifactId>
 <version>2.1.10</version>
 </dependency>
 
 <dependency>
 <groupId>org.dom4j</groupId>
 <artifactId>dom4j</artifactId>
 <version>2.0.0-RC1</version>
 </dependency>

本文出自 全栈笔记 版权所有,你可以在保留原文地址:JSTL JavaScript 冲突 HTTP Status 500 – Unable to compile class for JSP 及作者的情况下到你的网站或博客。

【上一篇】
【下一篇】

您可能感兴趣的文章:

发表评论

您必须 登录 后才能发表评论。