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.
NoNaMe
  • 6,020
  • 30
  • 82
  • 110
Anji
  • 1
  • what is the version of your JDK? – wero Oct 02 '15 at 10:52
  • are you using java 8? – Rahman Oct 02 '15 at 10:52
  • yes , am using JDK 8 and while tomcat installation , it auto searched for JRE c:\program files (X86)\java\jre6 – Anji Oct 02 '15 at 10:55
  • Possible duplicate of [The type java.lang.CharSequence cannot be resolved in package declaration](http://stackoverflow.com/questions/24301986/the-type-java-lang-charsequence-cannot-be-resolved-in-package-declaration) – wero Oct 02 '15 at 11:03

1 Answers1

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

Community
  • 1
  • 1
Rahman
  • 3,755
  • 3
  • 26
  • 43