42

I have downloaded Eclipse and tried to create a sample servlet program but I got following error

The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

I have configured build path correctly. I am using Java 8 and Apache Tomcat 7 and libraries for both are referenced correctly.

Problem is specifically for Java EE only. Ordinarily Java SE projects are running fine.

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
user3891270
  • 341
  • 1
  • 3
  • 6
  • What specific Java 8 version is this about? – mzjn May 02 '16 at 11:06
  • 2
    I am getting the same exception with both jdk and jre Version 8 Update 91. – ibrahim gürses May 02 '16 at 11:40
  • 1
    Red Hat issue related to this : https://access.redhat.com/solutions/2294701 – ibrahim gürses May 03 '16 at 10:57
  • @İbrahimGürses I can't access it due to login restrictions. It would be kind if you could post the conclusion or solution if there is any. – flob May 03 '16 at 12:08
  • @flob: The suggested resolution is "Consider precompiling JSPs as a workaround". There is also a link to a reopened bug report (1223609) and note that says "ecj is an older version that does not support java 8". I don't know what to make of that. There was no problem with Java 8 Update 77 AFAIK. – mzjn May 09 '16 at 05:55
  • The following bug was resolved on May 2 as "not an issue" with this comment: "Closing as not an issue. This should be resolved by upgrading to latest versions of Tomcat." https://bugs.openjdk.java.net/browse/JDK-8155588. A customer submitted workaround says "the only work around is to go back older JDK/JRE version and pray that the glitch will go away with the new release". – mzjn May 09 '16 at 07:26
  • In a comment in this Red Hat issue, https://bugzilla.redhat.com/show_bug.cgi?id=1336481, the following vulnerability is mentioned: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-3427. It is also in Oracle Critical Patch Update Advisory - April 2016: http://www.oracle.com/technetwork/security-advisory/cpuapr2016v3-2985753.html. – mzjn May 20 '16 at 11:10
  • I have same problem with JDK 1.8.0_191 . Then I have change it 1.8.0_162 and its working now – Devendra Singraul Dec 06 '18 at 14:53

10 Answers10

38

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:

All these are about problems with Java 8 Update 91 (or later) that are not present when using earlier JRE/JDK versions.


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.

The Update 91 release notes document mentions JDK-8144430 (non-public ticket): 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.

Community
  • 1
  • 1
mzjn
  • 42,096
  • 9
  • 100
  • 209
  • 2
    facing the same issue but once I move to tomcat 7 things are working fine..using jdk8_121 – dom Mar 16 '17 at 15:37
  • @dom, in the question it says "I am using Java 8 and Apache Tomcat 7". So what do you mean by "once I move to tomcat 7"? – mzjn Mar 19 '17 at 08:57
5

You simply need to upgrade your Tomcat version, to Tomcat 8.0.xx. Java8 <-> Tomcat8

This is the configuration that I have been using and it has always worked out well JDK version Tomcat versions

Ismael Sarmento
  • 485
  • 5
  • 13
  • 1
    To me it seems like a bug in Java 8 Update 91. I doubt that upgrading Tomcat will fix the issue for everyone. See http://stackoverflow.com/questions/36981733/unable-to-compile-jsp-file-with-jdk1-8-0-92#comment62126450_36981733-. – mzjn Jul 22 '16 at 19:06
  • @user3891270: Does this answer help? Does it work if you upgrade to Tomcat 8? – mzjn Jul 23 '16 at 10:53
  • 1
    Runtime Environments->Add->Apache->till 7 version i could find but 8th version of apache is not shown.How to add it externally.Please help me bro – Ganesh Chowdhary Sadanala Jan 09 '19 at 15:26
  • @GaneshChowdharySadanala what version of Eclipse are you using? I suggest you to use new versions; they are faster, they still support old versions of java and more stable. You should find Apache 7 from version Kepler (4.3) on. https://www.eclipse.org/downloads/ – Ismael Sarmento Jan 15 '19 at 00:37
  • @mzjn it seems that from Update 92 on, the issue is solved; we still need to have a compatible version of Tomcat. – Ismael Sarmento Jan 15 '19 at 00:42
  • 1
    @IsmaelSarmento yeah I just resolved it by installing new version of eclipse jee – Ganesh Chowdhary Sadanala Jan 16 '19 at 12:01
2

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.

AmitB10
  • 385
  • 4
  • 14
2

Using the latest 7.x Tomcat (currently 7.0.69) solved the problem for me.

We did also try a workaround in a old eclipse bug, maybe that did it's part to solve the problem, too?

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
metin.n
  • 21
  • 3
  • I am upgrading to tomcat-7.0.70, and i am seeing the problem in some cases. I use SUSE Linux version 12 and all is copacetic, but i have an older machine on version 11 SP 3, and that one still has the error with JDK_1.8.0_91. – Jeff Jul 27 '16 at 19:30
1

Workaround:

Window -> Preferences -> Java -> Installed JREs, select a different JRE

maybe this JDK edition is not suitable:

enter image description here


So try this one instead:

enter image description here

Problem solved!

JonasCz
  • 11,174
  • 6
  • 40
  • 61
Phoenix
  • 19
  • 2
  • 1
    Exercise caution when downgrading -- it's worth noting that there are many known security vulnerabilities in prior versions of Java. – Jeff Jul 27 '16 at 19:31
1

Upgrading to tomcat 7.0.70 resolved the issue for me

Gavy
  • 222
  • 2
  • 8
1

Okay, this question was a year ago but I recently got this problem as well.

So what I did :

  1. Update tomcat 7 to tomcat 8.
  2. Update to the latest java (java 1.8.0_141).
  3. 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)

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.

kaixas K
  • 85
  • 10
1

I am using Google appengine java sdk and was facing similar issue. I had to add

<runtime>java8</runtime>

in appengine-web.xml file to make it work.

Aniket Thakur
  • 58,991
  • 35
  • 252
  • 267
1

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

mohsen.nour
  • 852
  • 3
  • 16
  • 24
0

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.

Touhid
  • 11