0

exception:

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 152 in the jsp file: /user.jsp The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files

 149:       int length=5;
    150:         for (int i = 0; i <= length; i++ ) {  
    151:             int pos = rand.nextInt(charset1.length()); 
    152:             sb.append(charset1.charAt(pos));  
    153:         }

Stacktrace:

    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
     org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
       org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
                    org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
                    org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
                   org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
                org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
                     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

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

1 Answer 1

0

Java 8 supports default methods in interfaces. And in JDK 8 a lot of old interfaces now have new default methods. For example, now in CharSequence we have chars and codePoints methods. If source level of your project is lower than 1.8, then compiler doesn't allow you to use default methods in interfaces. So it cannot compile classes that directly on indirectly depend on this interfaces. If I get your problem right, then you have two solutions. First solution is to rollback to JDK 7, then you will use old CharSequence interface without default methods. Second solution is to set source level of your project to 1.8, then your compiler will not complain about default methods in interfaces.

Ref : The type java.lang.CharSequence cannot be resolved in package declaration

4
  • Now I used JDK 7, even it is showing the same error. Do I need to reinstall tomcat?
    – Anji
    Oct 2, 2015 at 11:11
  • I have changed the JAVA_HOME system variable path to C:\Program Files\Java\jdk1.7.0 Even it is showing the same error
    – Anji
    Oct 2, 2015 at 11:13
  • What is the source level in eclipse ? 1.8 ?
    – Rahman
    Oct 2, 2015 at 11:15
  • I didn't get you. But I am not using Eclipse
    – Anji
    Oct 2, 2015 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.