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"); %>
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.
This can happen without apparent reason when you run out of disk space. Tomcat cant create the class file but goes ahead and inappropriately assumes it was successful, and then complains latter.
Another reason for this exception might be lack of write permission. If tomcat was started on linux machine by a root user it will create work/ directory with owner root. If you will try to start tomcat with special user that has lesser permissions it will fail to compile JSP files because of that. So you might try two solutions:
chown tomcat_user -R work/
rm -R work/
I had similar problem on the spring template Spring MVC
hello world example,generated by IntelliJ. The InternalResourceViewResolver would not resolve the Hello_JSP.java file. I had to change it to following dependency
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency>
Hope it can help someone.
I was getting this error because I had a JSP API dependency in my WAR's pom.xml:
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
Changing it to this fixed it:
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
One assumes this is due to a duplicate class being present during the compile phase. Without BalusC explaining it's a compilation issue I'd have never guessed!
I was also facing this problem which is due to library jar files like jetty-util-6.0.0rc0.jar, jasper-compiler-jdt-5.5.23.jar, jasperreports-3.0.0.jar. My answer may not be proper because right now I'm a beginner but at least you can try... Thank u,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.