Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
127 views
in Technique[技术] by (71.8m points)

java - Unable to load class for JSP

Exception stack trace

org.apache.jasper.JasperException: Unable to load class for JSP
 org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:599)
 org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:143)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:321)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

java.lang.ClassNotFoundException: org.apache.jsp.redirect_jsp
 java.net.URLClassLoader$1.run(Unknown Source)
 java.security.AccessController.doPrivileged(Native Method)
 java.net.URLClassLoader.findClass(Unknown Source)
 org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:131)
 org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
 org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:597)
 org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:143)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:321)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

My redirect.jsp file contents

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% response.sendRedirect("user/list.htm"); %>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Under the covers of the servletcontainer, JSP's are compiled to Java classes before they get executed.

The exception

java.lang.ClassNotFoundException: org.apache.jsp.redirect_jsp

means that the redirect.jsp file in the root of your webcontent folder failed to compile which in turn often means that it contains some raw Java code in scriptlets <% %> which contains syntax errors. You need to fix those syntax errors so that the servletcontainer can compile those JSP files. The general concensus is however that scriptlets are a poor practice. You should consider if that Java code doesn't better belong in a fullworthy Java class, controlled by a Servlet or a Filter.

Another possible cause is that the work cache of the servletcontainer is messed up. This can happen when developing with a poor IDE plugin. You'd like to clean the work cache. In for example Eclipse, you can do that by rightclick the server and choosing Clean. Otherwise it has to be done manually by deleting everything in work cache of the servletcontainer in question. In case of for example Tomcat, that's then everything in side its /work folder.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...