当前位置: 代码迷 >> Java Web开发 >> 一个Unable to compile class for JSP异常
  详细解决方案

一个Unable to compile class for JSP异常

热度:124   发布时间:2016-04-17 16:25:40.0
一个Unable to compile class for JSP错误?
我用的是eclipse(3.2)+myeclipse(5.1)
jdk(1.4.2_04)
tomcat(5.0.28)

jsp文件放在WebRoot下,java文件放在src的cn.com.shoppingonline包中,
.class文件放在classes的cn.com.shoppingonline包中.

其中一个left.jsp代码如下:
<%@   page   contentType= "text/html;charset=UTF-8 "   language= "java "   %>
<%@   page   import   =   "cn.com.shoppingonline.* "   %>
<%@   page   import   =   "java.util.* "   %>

<%
List   sortList   =   (List)session.getAttribute(Constants.SORT_LIST_KEY);
Sort   sort   =   null;
%>


运行这个jsp文件报如下错误:
HTTP   Status   500   -  

--------------------------------------------

type   Exception   report

message  

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

An   error   occurred   at   line:   5   in   the   jsp   file:   /left.jsp
Generated   servlet   error:
D:\jakarta-tomcat-5.0.28\work\Catalina\localhost\ShoppingOnline\org\apache\jsp\left_jsp.java:49:   cannot   access   cn.com.shoppingonline.Constants


An   error   occurred   at   line:   5   in   the   jsp   file:   /left.jsp
Generated   servlet   error:
bad   class   file:   D:\jakarta-tomcat-5.0.28\webapps\ShoppingOnline\WEB-INF\classes\cn\com\shoppingonline\Constants.class
class   file   has   wrong   version   49.0,   should   be   48.0
Please   remove   or   make   sure   it   appears   in   the   correct   subdirectory   of   the   classpath.
List   sortList   =   (List)session.getAttribute(Constants.SORT_LIST_KEY);
                                                                                                      ^
1   error


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Apache   Tomcat/5.0.28   logs.


--------------------------------------------
  相关解决方案