1

I am attempting to set up a Jetty Webapp project in Eclipse Neon and am getting the following error: Generated servlet error: The type java.lang.CharSequence cannot be resolved

Based on this related post and a few others, I’ve been led to believe this being caused by a version mismatch between Java 7 and Java 8. The project also runs properly on other machines, which also would imply the issue is with my configuration. The accepted answer to the linked post is to either roll back to Java 7, or change the source level of the project to 8. Rolling back to 7 is not an option for me, as the project makes use of Java 8 features.

Im pretty sure I have everything set up for Java 8, but I’m not real experienced in Eclipse, so there could be a setting Im missing. I have set:

in Eclipse->Preferences->Java->Compiler->Compiler compliance level: 1.8

in Project->Preferences->Java Compiler->Compiler compliance level: 1.8

in Project->Preferences->Java Build Path->Libraries the JRE System Library is 1.8.0_77

in Run->Run Configurations->Jetty Webapp: Jetty Version is Jetty 7.6.8v20121106 JRE is Project JRE (1.8.0_77)

I have also cleaned, rebuilt, removed and reimported the project, and restarted Eclipse.

Are there any settings I am missing that might still be set to Java 7? Or is there some other reason why I would be getting this error?

the full error message is:

org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP||PWC6197: An error occurred at line: 17 in the jsp file: /WEB-INF/jsp/dashboard/showfilters.jsp|PWC6199: Generated servlet error:|The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files||PWC6197: An error occurred at line: 17 in the jsp file: /WEB-INF/jsp/dashboard/showfilters.jsp|PWC6199: Generated servlet error:|The method replace(char, char) in the type String is not applicable for the arguments (String, String)||
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:123)

Also, the line in question is:

<a title=" <%= request.getAttribute("title").toString().replace("],", "\n") %>"></a>
Community
  • 1
  • 1
bradimus
  • 825
  • 11
  • 25
  • Try this: – Mechkov Nov 01 '16 at 19:05
  • `Generated servlet error: The type java.lang.CharSequence cannot be resolved` - This has nothing to do with Java 8 itself. `CharSequence` exists since java 5, so if you're getting this error there is some serious misconfiguration in your project. By the way, if your project is a maven project, check the [java version configuration](https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html) – BackSlash Nov 01 '16 at 19:07
  • I'll try it real quick but ']' and ',' are two characters right? Also, it runs on other machines so Im pretty sure configuration? – bradimus Nov 01 '16 at 19:07
  • @BackSlash its a gradle project, which Im also not super familiar with :( – bradimus Nov 01 '16 at 19:09
  • 1
    @bradimus Then [this question](http://stackoverflow.com/questions/18487406/how-do-i-tell-gradle-to-use-specific-jdk-version) might help you – BackSlash Nov 01 '16 at 19:11
  • `replace(String, String)` came later than `replace(char, char)`. And it is the **JSP compiler** that seems to be using an older version. I am not now at some eclipse compiler, but look at the JSP settings, like pre-compilation too. 1.6? – Joop Eggen Nov 01 '16 at 19:19
  • [Jetty 7 is EOL (End of Life)](https://dev.eclipse.org/mhonarc/lists/jetty-announce/msg00069.html) and does not support Java 8 (initial support for Java 8 was added in Jetty 8), also, the JSP engine does not support Java 8 (Jetty 9.3 is the first time for JSP support of Java 8) – Joakim Erdfelt Nov 01 '16 at 20:57
  • @JoakimErdfelt Thanks updating my version of Jetty fixed the problem. I wasn't able to go to 9, I got a bunch of `NoSuchMethodError: org.eclipse.jetty.util.MultiMap.add` coming from the `AnnotationParser`. But I managed to get it working with Jetty 8.1.8 so we must not be using Java 8 in JSP. If you want to make this an answer I'll accept it. – bradimus Nov 01 '16 at 21:29

0 Answers0