Unable to compile class for JSP: The type java.util.Map$Entry cannot be resolved

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:

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

	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)

Here is error in browser:
The type java.util.Map$Entry cannot be resolved to a type

And here is the same error in Eclipse development environment:
Error java.util.Map$Entry cannot be resolved

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.

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.

Delete Apache Tomcat from Eclipse

And then confirm action and do not forget to click Delete unused server configuration(s) check box.

Eclipse Confirm Delete Tomcat

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.

Java Eclipse Add Apache Tomcat

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).

Eclipse Tomcat Specify Path to It

After those steps everything should be OK. Happy codding.

Related Posts Plugin for WordPress, Blogger...

  • Michael Webb

    For me, the solution was to use a later ecj jar file, ecj-4.4.2.jar

  • Sagili Ramanareddy

    thanks really it will be helpful me