2

I have a project in which I'm going in this way

  1. Create Account ->Show Menu. On selecting choice 1 ->SelectPost.jsp

and from a previously created account:

  1. Login -> Show Menu. On selecting choice 1 ->SelectPost.jsp

Whenever I follow path 1 I get this exception, which I don't get on following path 2:

org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.SelectPost_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:168)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

root cause

java.lang.ClassNotFoundException: org.apache.jsp.SelectPost_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:366)
java.net.URLClassLoader$1.run(URLClassLoader.java:355)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:354)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:132)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:162)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

I cannot seem to find out the error. It is working fine one way but not the other. Otherwise, the whole project is working fine. Can anybody tell me what to do?

Update: Now its showing the same error in both the paths.

user2816215
  • 399
  • 1
  • 4
  • 17
  • Sounds like you could have multiple copies of the same class on your class path. Have you checked you have one and only one jsp-api jar on your classpath? – user1886323 Aug 03 '15 at 19:40
  • Actually, as you have edited the question to say the error occur both times, it's probably that you don't have the jsp-api on your classpath. – user1886323 Aug 03 '15 at 19:40
  • Um, can you explain that better? How to do in that case? The file is working stand-alone. If I run it, it works. One going from another file to this particular file, the error occurs. – user2816215 Aug 03 '15 at 19:45
  • Should I google the jsp-api thing? It has never been an issue before. And everything else is working fine. – user2816215 Aug 03 '15 at 19:46
  • Yes, the first thing one should do when you get ClassNotFoundException is to google the package name (org.apache.jsp) to find out what JAR this class is in. Then you need to check your IDE is configured to load this JAR onto the classpath. – user1886323 Aug 03 '15 at 19:49
  • Can you make it a little detailed? Or point me to a link perhaps? I was looking at this: http://javarevisited.blogspot.sg/2011/01/how-classpath-work-in-java.html and it is a little unclear at some spots. Or do you perhaps mean: /WEB-INF/lib/*.jar – user2816215 Aug 03 '15 at 20:02

1 Answers1

1

I found out that the exception

java.lang.ClassNotFoundException means that the SelectPost.jsp file in the root of my webcontent folder failed to compile which basically happened because I had raw Java code in scriptlets <% %> which contained syntax errors. After fixing those syntax errors the servletcontainer complied the JSP files.

Source: Answer to this question: Unable to load class for JSP

Community
  • 1
  • 1
user2816215
  • 399
  • 1
  • 4
  • 17