“无法解析 java.util.Map$Entry 类型”(tomcat6 + JDK7)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30643933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"The type java.util.Map$Entry cannot be resolved" (tomcat6 + JDK7)
提问by Btc Sources
I've a JSP app which gives me the error:
我有一个 JSP 应用程序,它给了我错误:
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).
Stackoverflow 有很多关于这个错误的帖子,但他们都解决了只.java
使用 JDK7编译文件,再加上使用相同版本的 tomcat(我的意思是,低于 JDK8,这似乎是问题所在,因为某些 IDE 版本和 tomcat 版本不支持)。
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.
问题是,我已经建立了我的应用程序(.java
文件)使用JDK 1.7.0_79
,再加上我在我所tomcat 6
使用的服务器的同一个。
So there's no JDK 8 anywhere... Some screenshots with data:
所以任何地方都没有 JDK 8 ......一些带有数据的屏幕截图:
My JVM directory:
我的JVM目录:
Error stacktrace:
错误堆栈跟踪:
Tomcat process (running using JDK7):
Tomcat 进程(使用 JDK7 运行):
Javac version used to compile:
用于编译的Javac版本:
Any idea about why do I still get this error?
关于为什么我仍然收到此错误的任何想法?
Thank you in advance
先感谢您
回答by Aaron Digulla
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.
使用 Java 6 运行 Tomcat 或升级到 Tomcat 7,并确保类路径上没有一些旧的 pre-Java 5/pre-generics 库。
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.
为什么会出现此错误?JSP 代码中的某处(不是您的代码,请注意)是对java.util.Map.Entry
. 这可能是 Jasper 从您的 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
它不是直接依赖;而是您的代码(或从您的 JSP 生成的 Java 代码)需要其他东西,然后需要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 nameof the class is the same (which makes the error so confusing) but the APIhas changed and the code can't find something (or found something it didn't expect).
但是界面在某些方面发生了变化。通常,这是在 Java 8 中,因为他们添加了新的静态帮助器方法:类的名称是相同的(这使得错误如此混乱)但API已更改并且代码无法找到某些东西(或找到某些东西)没想到)。
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.
更糟糕的是,import java.util.Map
在你的 JSP 工程中。导致麻烦的是其他地方的现有字节码。
[EDIT]
[编辑]
In my
/WEB-INF/lib/
folder I've:commons-fileupload
,commons-io
,poi
andrt
(may this one be the problem?)
在我的
/WEB-INF/lib/
文件夹我有:commons-fileupload
,commons-io
,poi
和rt
(可能这一个问题?)
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.
是的:-)rt.jar
是 Java 运行时。它包含java.*
并且在您的情况下,其版本java.util.Map
与您的 Java VM 中的版本不匹配。
Remote it and it should work.
远程它,它应该工作。
回答by Sandney Farias
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.
我在 Eclipse Mars、JDK 8 和 Tomcat Maven Plugin 上遇到了同样的问题。解决了在我的 pom.xml 中将插件版本更改为 2.2 的问题。
回答by user3712161
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
我有 tomcat-7.0.22 和 jdk1.8.0_45,我用包含在 tomcat-8.0.43 中的 ecj-4.6.1.jar 文件替换了 tomcat/lib 目录中的 ecj-3.7.jar 文件,然后得到摆脱错误。有关更多信息,请查看这篇文章如何更改 tomcat 编译器