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
* 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).
*上满是关于这个错误的帖子,但是所有的问题都可以通过使用JDK7编译.java文件,再加上使用相同版本的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.
问题是我建立了我的应用。使用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
提前谢谢你
3 个解决方案
#1
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.
使用Java 6运行Tomcat或升级到Tomcat 7,并确保在类路径中没有一些旧的Java前5/前泛型库。
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代码中的某个地方(不是您的代码,mind)是对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 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).
但是界面在某种程度上发生了变化。通常情况下,这是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.
更糟糕的是,进口java.util。在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/文件夹中:common -fileupload、common -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的一个版本。映射不匹配Java VM中的映射。
Remote it and it should work.
远程操作,它应该可以工作。
#2
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.
我对Eclipse Mars、JDK 8和Tomcat Maven插件也有同样的问题。在我的blog .xml中将插件版本更改为2.2就解决了这个问题。
#3
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
我有tomcat-7.0.22和jdk1.8.0_45,我替换了ecj-3.7。使用ecj-4.6.1在tomcat/lib目录中的jar文件。tomcat8 .0.43中包含的jar文件,它消除了错误。有关更多信息,请阅读本文,了解如何更改tomcat编译器
#1
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.
使用Java 6运行Tomcat或升级到Tomcat 7,并确保在类路径中没有一些旧的Java前5/前泛型库。
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代码中的某个地方(不是您的代码,mind)是对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 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).
但是界面在某种程度上发生了变化。通常情况下,这是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.
更糟糕的是,进口java.util。在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/文件夹中:common -fileupload、common -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的一个版本。映射不匹配Java VM中的映射。
Remote it and it should work.
远程操作,它应该可以工作。
#2
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.
我对Eclipse Mars、JDK 8和Tomcat Maven插件也有同样的问题。在我的blog .xml中将插件版本更改为2.2就解决了这个问题。
#3
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
我有tomcat-7.0.22和jdk1.8.0_45,我替换了ecj-3.7。使用ecj-4.6.1在tomcat/lib目录中的jar文件。tomcat8 .0.43中包含的jar文件,它消除了错误。有关更多信息,请阅读本文,了解如何更改tomcat编译器