Recently I update to Java 1.8, but still was using for development some old installation of Eclipse and Tomcat. When I updated I got very strange error. Usually updating JDK from old versions to new one should not be a problem. Java is well known for it backward compatibility. And not only Java, but Tomcat, Eclispe and other Java related products usually are backward compatible. And updates usually are flawless. But the problem was serious. I was not able to run any of my web related projects. They compile without error. But when deployed this error happens. And that is why I feel a little bit confused. But here is a description of error:
Advertisements
VII 02, 2015 6:07:17 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [jsp] in context with path [] threw exception [Unable to compile class for JSP: An error occurred at line: 1 in the generated java file The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files Stacktrace:] with root cause org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 1 in the generated java file The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files Stacktrace: at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102) at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331) at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) ... ...
And here is the same error in Eclipse development environment:
After searching in Google and reading couple of posts in Stack Exchange I found the problem. It is caused by using old version of Tomcat 7 – prior version Tomcat 7.0.54. So I was using Tomcat 7.0.32 which was not exactly compatible with Java 8. There was one jar file that brakes it – ecj-3.7.2.jar. In latest version of Tomcat in 7.0.xx series it is replaced with ecj-4.2.2.jar. So once updated to latest 7.0.xx which of time of writing this post is 7.0.63 – error disappears and everything was running perfect.
Advertisements
Here is how to do that in Eclipse:
First you need to delete old version of Tomcat. This is done by going to Servers tab and selecting server you want to delete and then right click and select Delete.
And then confirm action and do not forget to click Delete unused server configuration(s) check box.
Next steps are to create new server. You should know how to do it. Go to Server Tab then right click on empty space and select New -> Server. Then select a Tomcat 7.0 and click Next button.
On next step do not forget to specify path to Tomcat setup directory. Usuayly I unzip it in the main directory and name it tomcat7 (or tomcat8 – depends of the version).
After those steps everything should be OK. Happy codding.