问题描述
我有一个JSP应用程序,它给了我错误:
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已经发布了关于此错误的帖子,但 所有人都解决了使用JDK7编译 .java
文件 ,以及使用相同版本的tomcat(我的意思是,以下是JDK8,这似乎是问题所在,因为有些IDE版本和tomcat版本不支持它。)
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).
问题在于我已经建立了我的应用( .java
文件)使用 JDK 1.7.0_79
,再加上我的 tomcat 6
服务器使用相同的。
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.
所以有没有任何JDK 8 ...一些数据截图:
So there's no JDK 8 anywhere... Some screenshots with data:
我的JVM目录:
错误堆栈跟踪:
Tomcat进程(使用JDK7运行):
Tomcat process (running using JDK7):
用于编译的Javac版本:
Javac version used to compile:
任何关于我为什么还能得到的想法这个错误?
Any idea about why do I still get this error?
提前谢谢
推荐答案
运行Tomcat Java 6或升级到Tomcat 7并确保在类路径上没有一些旧的Java 5 / pre-generics库。
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.
为什么你会得到这个错误? JSP代码中的某个地方(不是您的代码,请注意)是对 java.util.Map.Entry
的依赖。这可能是Jasper从JSP生成的代码。
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代码)需要其他需要的东西 java.util.Map.Entry
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
但界面已经有所改变。通常,这与Java 8一样,因为他们添加了新的静态辅助方法:类的名称是相同的(这使得错误如此混乱)但是 API 已经改变了,代码找不到东西(或发现了一些它没想到的东西)。
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).
更糟糕的是,在JSP中导入java.util.Map
作品。这是其他地方的现有字节码造成麻烦。
Even worse, import java.util.Map
in your JSP works. It's the existing bytecode somewhere else that causes the trouble.
是:-) rt.jar
是Java运行时。它包含 java。*
,在您的情况下, java.util.Map
的版本与一个来自你的Java VM。
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.
远程它,它应该工作。
这篇关于“类型java.util.Map $ Entry无法解析” (tomcat6 + JDK7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!