无法解析 java.io.ObjectInputStream 类型。它是从所需的 .class 文件间接引用的
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36963248/
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.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files
提问by user3891270
I have downloaded Eclipse and tried to create a sample servlet program but I got following error
我已经下载了 Eclipse 并尝试创建一个示例 servlet 程序,但出现以下错误
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files
无法解析 java.io.ObjectInputStream 类型。它是从所需的 .class 文件间接引用的
I have configured build path correctly. I am using Java 8 and Apache Tomcat 7 and libraries for both are referenced correctly.
我已经正确配置了构建路径。我正在使用 Java 8 和 Apache Tomcat 7,并且它们的库都被正确引用。
Problem is specifically for Java EE only. Ordinarily Java SE projects are running fine.
问题仅针对 Java EE。通常 Java SE 项目运行良好。
回答by AmitB10
same problem with me. This is not a solution but a workaround, which worked for me: Buildpath->Configure buildpath->Libraries-> Here remove the JRE system library pointing to JRE8 and add JRE system library for JRE7.
我也有同样的问题。这不是解决方案,而是一种变通方法,对我有用:Buildpath->Configure buildpath->Libraries-> 此处删除指向 JRE8 的 JRE 系统库并为 JRE7 添加 JRE 系统库。
回答by metin.n
Using the latest 7.x Tomcat (currently 7.0.69) solved the problemfor me.
使用最新的 7.x Tomcat(目前为 7.0.69)为我解决了这个问题。
We did also try a workaround in a old eclipse bug, maybe that did it's part to solve the problem, too?
我们也尝试过解决旧的 Eclipse 错误,也许这也是解决问题的一部分?
https://bugs.eclipse.org/bugs/show_bug.cgi?id=67414
https://bugs.eclipse.org/bugs/show_bug.cgi?id=67414
Workaround:
解决方法:
- Window->Preferences->Java->Installed JREs
- Uncheck selected JRE
- Click OK (this step may be optional?)
- Check JRE again
- Window->Preferences->Java->Installed JREs
- 取消选中选定的 JRE
- 单击确定(此步骤可能是可选的?)
- 再次检查 JRE
回答by Phoenix
Workaround:
解决方法:
Window-> Preferences-> Java-> Installed JREs, select a different JRE
Window-> Preferences-> Java-> Installed JREs,选择不同的 JRE
maybe this JDK edition is not suitable:
也许这个JDK版本不适合:
So try this one instead:
所以试试这个:
Problem solved!
问题解决了!
回答by mzjn
Something happened in Java 8 Update 91 that broke existing JSP code. That seems pretty clear. Here is a sample of similar questions and bug reports:
Java 8 Update 91 中发生了一些破坏现有 JSP 代码的事情。这似乎很清楚。以下是类似问题和错误报告的示例:
- Unable to compile JSP file with JDK1.8.0_92
- Spring MVC - Unable to compile class for JSP
- Unable to access CloudPlatform Client
- https://bugs.openjdk.java.net/browse/JDK-8155588(closed as "not an issue")
- https://bugs.openjdk.java.net/browse/JDK-8155223(closed as "not an issue")
- https://access.redhat.com/solutions/2294701
- https://alluxio.atlassian.net/browse/ALLUXIO-1956
- https://jira.atlassian.com/browse/CWD-4729
- https://community.exoplatform.com/portal/intranet/forum/topic/topic991e097d9e45345236bb2bd1920a4c68
- https://issues.apache.org/jira/browse/OOZIE-2533(from a comment: "This is really looking like a JDK bug")
- https://bugzilla.redhat.com/show_bug.cgi?id=1337940(comment 2 mentions the change to
java.io.ObjectInputStream
in Update 91 that "made it incompatible with RHEL6's current ECJ version") - https://github.com/mit-cml/appinventor-sources/issues/814
- https://community.oracle.com/thread/3953395
- 无法使用 JDK1.8.0_92 编译 JSP 文件
- Spring MVC - 无法为 JSP 编译类
- 无法访问 CloudPlatform 客户端
- https://bugs.openjdk.java.net/browse/JDK-8155588(关闭为“不是问题”)
- https://bugs.openjdk.java.net/browse/JDK-8155223(关闭为“不是问题”)
- https://access.redhat.com/solutions/2294701
- https://alluxio.atlassian.net/browse/ALLUXIO-1956
- https://jira.atlassian.com/browse/CWD-4729
- https://community.exoplatform.com/portal/intranet/forum/topic/topic991e097d9e45345236bb2bd1920a4c68
- https://issues.apache.org/jira/browse/OOZIE-2533(来自评论:“这真的看起来像一个 JDK 错误”)
- https://bugzilla.redhat.com/show_bug.cgi?id=1337940(评论 2 提到
java.io.ObjectInputStream
更新 91中的更改“使其与 RHEL6 的当前 ECJ 版本不兼容”) - https://github.com/mit-cml/appinventor-sources/issues/814
- https://community.oracle.com/thread/3953395
All these are about problems with Java 8 Update 91 (or later) that are not present when using earlier JRE/JDK versions.
所有这些都是关于 Java 8 Update 91(或更高版本)的问题,这些问题在使用早期 JRE/JDK 版本时不存在。
The following OpenJDK changeset from 22 January 2016 appears to be related: http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/32f64c19b5fb(commit message "8144430: Improve JMX connections"). The changeset seems to be related to this vulnerability, https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-3427, which is mentioned in a comment to this Red Hat bug report, https://bugzilla.redhat.com/show_bug.cgi?id=1336481.
以下来自 2016 年 1 月 22 日的 OpenJDK 变更集似乎相关:http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/32f64c19b5fb(提交消息“8144430:改进 JMX 连接”)。变更集似乎与此漏洞有关,https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-3427 ,在对此 Red Hat 错误报告的评论中提到,https ://bugzilla.redhat.com/show_bug.cgi?id=1336481。
The Update 91 release notes document mentions JDK-8144430 (non-public ticket): http://www.oracle.com/technetwork/java/javase/8u91-relnotes-2949462.html.
Update 91 发行说明文档提到了 JDK-8144430(非公开票):http: //www.oracle.com/technetwork/java/javase/8u91-relnotes-2949462.html。
In "Oracle Critical Patch Update Advisory - April 2016", the CVE-2016-3427 vulnerability is mentioned: http://www.oracle.com/technetwork/security-advisory/cpuapr2016v3-2985753.html.
在“Oracle 重要补丁更新咨询 - 2016 年 4 月”中,提到了 CVE-2016-3427 漏洞:http: //www.oracle.com/technetwork/security-advisory/cpuapr2016v3-2985753.html。
回答by Ismael Sarmento
回答by Gavy
Upgrading to tomcat 7.0.70 resolved the issue for me
升级到 tomcat 7.0.70 为我解决了这个问题
回答by Touhid
I was also facing same issue. I had Jdk1.7.0.79. Then I updated it with Jdk8.0.120. Then the problem solved. After successful completion of upgraded jdk. Go to project->clean. It will rebuild the project and all red alert will be eliminated.
我也面临同样的问题。我有 Jdk1.7.0.79。然后我用Jdk8.0.120更新了它。然后问题就解决了。升级jdk后顺利完成。转到项目-> 清洁。它将重建项目并消除所有红色警报。
回答by kaixas K
Okay, this question was a year ago but I recently got this problem as well.
好的,这个问题是一年前的,但我最近也遇到了这个问题。
So what I did :
所以我做了什么:
- Update tomcat 7 to tomcat 8.
- Update to the latest java (java 1.8.0_141).
- Update the JRE System Library in Project > Properties > Java Build Path. Make sure it has the latest version which in my case is jre1.8.0_141 (before it was the previous version jre1.8.0_111)
- 将 tomcat 7 更新为 tomcat 8。
- 更新到最新的 java (java 1.8.0_141)。
- 在Project > Properties > Java Build Path 中更新 JRE 系统库。确保它具有最新版本,在我的情况下是 jre1.8.0_141(在之前的版本 jre1.8.0_111 之前)
When I did the first two steps it still doesn't remove the error so the last step is important. It didn't automatically change the build path for jre.
当我执行前两个步骤时,它仍然没有消除错误,因此最后一步很重要。它没有自动更改 jre 的构建路径。
回答by Aniket Thakur
I am using Google appengine java sdk and was facing similar issue. I had to add
我正在使用 Google appengine java sdk 并面临类似的问题。我不得不添加
<runtime>java8</runtime>
in appengine-web.xml file to make it work.
在 appengine-web.xml 文件中使其工作。
回答by mohsen.nour
Reason : Old versions of Tomcat 6 JSP compiler don't seem to be aware of JDK 8 constant pool enhancements - eg. method handles. New code in JDK 8u is using a method handle instead of creating an anonymous class. This will cause the method handle to be listed in the constant pool and the eclipse compiler will choke on this - https://bz.apache.org/bugzilla/show_bug.cgi?id=56613
原因:旧版本的 Tomcat 6 JSP 编译器似乎不知道 JDK 8 常量池增强 - 例如。方法句柄。JDK 8u 中的新代码使用方法句柄而不是创建匿名类。这将导致方法句柄被列在常量池中,并且 eclipse 编译器将对此感到窒息 - https://bz.apache.org/bugzilla/show_bug.cgi?id=56613