2

I've a JSP app which gives me the error:

The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

Stackoverflow is full of post about this error, but all of them get to solve just compiling the .java files using JDK7, plus using tomcat with same version (I mean, below to JDK8 which seems to be the problem, because some IDE version and tomcat versions doesn't support it).

The problem is that I've built my app (.java files) using JDK 1.7.0_79, plus I've my tomcat 6 server using the same one.

So there's no JDK 8 anywhere... Some screenshots with data:

My JVM directory:

enter image description here

Error stacktrace:

enter image description here

Tomcat process (running using JDK7):

enter image description here

Javac version used to compile:

enter image description here

Any idea about why do I still get this error?

Thank you in advance

Btc Sources
  • 1,912
  • 2
  • 30
  • 58
  • Are you building from the command line or using an IDE? Are you _certain_ that the JDK 7 is being used during the build? What is your _JAVAHOME_ set to? – Tim Biegeleisen Jun 04 '15 at 12:47
  • I'm building from the command line (using a script made by me) @TimBiegeleisen – Btc Sources Jun 04 '15 at 12:49
  • Is it possible that you have a JAR which requires Java 8? Which dependencies are you using? – Tim Biegeleisen Jun 04 '15 at 12:52
  • My `JAVA_HOME` is set in `/etc/default/tomcat6` like `JAVA_HOME=/usr/lib/jvm/jdk1.7.0_79`. About my JAR I guess it's possible, but I don't think so because until I added the code which used `Map` class to my JSP file I didn't have any problems with my JSP App. – Btc Sources Jun 04 '15 at 12:59

3 Answers3

4

Run Tomcat with Java 6 or upgrade to Tomcat 7 and make sure you don't have some old pre-Java 5/pre-generics library on the classpath.

Why do you get this error? Somewhere in the JSP code (not your code, mind), is a dependency on java.util.Map.Entry. This could be in code which Jasper generates from your JSP.

It's not a direct dependency; rather your code (or the Java code generated from your JSP) needs something else which then needs java.util.Map.Entry

But the interface has changed in some way. Usually, that's with Java 8 because of the new static helper methods which they added: The name of the class is the same (which makes the error so confusing) but the API has changed and the code can't find something (or found something it didn't expect).

A similar problem can happen when you try to compile against a pre-generics class (even though that should work).

Even worse, import java.util.Map in your JSP works. It's the existing bytecode somewhere else that causes the trouble.

[EDIT]

In my /WEB-INF/lib/ folder I've: commons-fileupload, commons-io, poi and rt (may this one be the problem?)

Yes :-) rt.jar is the Java runtime. It contains java.* and in your case, a version of java.util.Map which doesn't match the one from your Java VM.

Remote it and it should work.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • I've tried both ways you've said, and none worked =( Right now I've just tried tomcat 7, and after configure it all and try to run my app, now I get a `ClassNotFoundException` at the time I open my webapp at browser, and this toggles with the same error as before, but even in the JSP files where `Map` class isn't used! It's weird since It seems like if my JSP file were a class and it cannot found it... Both errors from access to a JSP file form my app here: http://pastebin.com/zdtyVAhA – Btc Sources Jun 04 '15 at 15:07
  • When `org.apache.jsp.manager_jsp` is missing, then half of the JSP compiler isn't there or you're mixing two JSP compilers. Are you sure that your installation is clean, the harddisk doesn't have dropouts/errors and you don't have odd stuff (like `jsp.jar`) on the classpath? Can you try with a basic app with just a single JSP? Maybe deploy the JSP demo app from Tomcat? – Aaron Digulla Jun 04 '15 at 15:23
  • The instalation was done just now using `apt-get`. The hard disk don't have any errors (at least known) and is in a virtual machine created two hours ago.. I've installed tomcat7-examples, tried some of them, `Tag Plugins` category fails, the other ones runs fine (tried >1 from each category). In my `/WEB-INF/lib/` folder I've: `commons-fileupload`, `commons-io`, `poi` and `rt` (may this one be the problem? I'm gonna try without it!). – Btc Sources Jun 04 '15 at 15:45
  • It worked! Now there's another error, but tomcat works fine, my app worked fine and is a code error of mine. Thanks so much for your help! – Btc Sources Jun 04 '15 at 15:55
  • I had, I don't remember why I needed to put it there >. – Btc Sources Jun 05 '15 at 09:36
1

I had the same problem with Eclipse Mars, JDK 8 and the Tomcat Maven Plugin. It was solved changing the plugin version to 2.2 in my pom.xml.

0

I have tomcat-7.0.22 and jdk1.8.0_45 and I replaced the ecj-3.7.jar file that is in tomcat/lib directory with ecj-4.6.1.jar file that's included in the tomcat-8.0.43 and that got rid of the error. for more information take a look at this post How to change tomcat compiler

Community
  • 1
  • 1