Eclipse can't find XML related classes after switching build path to JDK 10

solar eclipse
lunar eclipse
eclipse 2019
solar eclipse 2019
next solar eclipse
solar eclipse glasses
solar and lunar eclipse
solar eclipse diagram

I'm developing on a Maven project (branch platform-bom_brussels-sr7) in Eclipse. When I recently tried switching the Java Build Path for the project to JDK 10, Eclipse build can no longer find classes such as javax.xml.xpath.XPath, org.w3c.dom.Document, or org.xml.sax.SAXException. It seems only XML related classes are impacted, mostly from the Maven dependency xml-apis-1.4.01.

Trying a Maven build from Eclipse works without errors. Ctrl-LeftClick on one of the supposedly missing classes finds the class and opens it in the Eclipse editor. It seems only the Eclipse build is impacted.

I tried several things, but none helped. I tried:

  • Project Clean
  • Different Eclipse Versions: Oxygen and Photon.
  • Running Eclipse itself with JDK 8 and JDK 10.
  • Changing Compiler Compliance level for the project. It builds with compliance level 8 and 10 under JDK 8 build path and fails for both with JDK 10 in build path.

Solar eclipse guide 2020: When, where & how to see them, This total eclipse will be visible from Chile and Argentina in the afternoon, and skywatchers can witness up to 2 minutes and 10 seconds of  An eclipse that occurs when the Moon is near its closest distance to Earth (i.e., near its perigee) can be a total eclipse because the Moon will appear to be large enough to completely cover the Sun's bright disk or photosphere; a total eclipse has a magnitude greater than or equal to 1.000.

This seems to have been reported as Eclipse Bug 536928. Maybe if everyone were to go vote on it it would get them to raise the priority.

Solar eclipse: 11 breathtaking photos that will *not* melt your retinas, The annual solar eclipse took place on June 21, and was visible over some parts of the world for nearly four hours. The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 350 open source projects, including runtimes, tools and frameworks.

Have seen something very similar under Eclipse 4.8.0 and JDK 10. E.g.

import org.w3c.dom.Element;

was failing to compile in Eclipse with: The import org.w3c.dom.Element cannot be resolved

Even so, pressing F3 (Open Declaration) on that import, Eclipse was able to open the interface definition - in this case under xml-apis-1.4.01.jar.

Meanwhile, builds from Maven direct were working fine.

In this case the fix was to remove this dependency from the pom.xml:

    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.4.01</version>
    </dependency>

Then the compile errors in Eclipse melted away. Following F3 again showed the Element interface - now under the java.xml module, under the JRE System Library under the project. Also the Maven build remained fine.

This feels like a problem with Eclipse resolving a class that it finds in both a JDK module and dependent .jar file.

Interestingly, in a separate environment, this time under Eclipse 4.9.0 and JDK 11, all is fine, with or without the xml-apis:1.4.01 dependency.

Eclipse, However, the region where a partial eclipse can be observed is much larger. The Moon's umbra will advance eastward at a rate of 1,700 km/h, until it no longer  Solar and Lunar Eclipses worldwide (1900 to 2199) with animations and maps of the eclipse path. Find eclipses in your location.

Lunar eclipse, A lunar eclipse occurs when the Moon moves into the Earth's shadow. This can occur only when the Sun, Earth, and Moon are exactly or very closely aligned (in​  A lunar eclipse is an astronomical event in which the Earth comes in between the Sun and the Moon, forming a straight line. As a result, the blue planet completely or partially blocks the sunlight from reaching the surface of the Moon. 02 /7 ​All about the lunar eclipse 2020

This is more of a work-around, but from my experience it can be resolved by going to the "Java Build Path", the "Order and Export" tab, and sending the "Maven Dependencies" to the bottom (so it's below the "JRE System Library").

Solar eclipse 2020: See June's annular eclipse on Sunday, in the Eastern Hemisphere will be treated to an annular solar eclipse total eclipse and edges of the sun can still be seen around the moon. Eclipse calculations usually accurate to a few seconds. The magnitude of the eclipse is -0.405. The penumbral magnitude of the eclipse is 0.568. The total duration of the eclipse is 3 hours, 18 minutes.

Solar Eclipse and Your Eyes, This glass will reduce the harmful rays that are emitted during the eclipse. Do not use if there are any scratches or damage to the glass. Mylar filters: Aluminized  This is NASA's official eclipse Web site. It contains maps and tables for 5,000 years of eclipses and includes information on eclipse photography, observing tips and eye safety.

Next Solar Eclipse in New York, The next solar eclipse will be on December 14, 2020. This eclipse will not be visible in New York, but you can follow it via our real-time animation. Next Solar  The only other time an annular solar eclipse coincides with the June solstice in this century is on June 21, 2039. High Magnitude, Narrow Path, Short Annularity The path of this rare solstice "ring of fire" eclipse is long—it spans across two continents, Africa and Asia, and 14 countries—but it is also very narrow.

Next Lunar Eclipse in New York, Find out when the next one is and if you can see it from your location. Total lunar eclipse over The next lunar eclipse will be on July 5, 2020. July 27/28, 2018  Our LIVE stream schedule of lunar and solar eclipses in 2020. Watch the "ring of fire" annular solar eclipse on June 21, 2020, online.

Comments
  • I don't know anything about Eclipse but the classes you list are in the java.xml module. If you were previously deploying xml-apis-1.4.01 on the class path then I assume the classes were never actually loaded from that JAR file, they were loaded (and continue to be loaded) from the JDK. Does your project build/run outside of Eclipse?
  • Yes, a maven command line build, or even a explicit maven build within Eclipse both work. It's just the Eclipse built-in build that fails.
  • You have to use Oxygen.1a or newer, the original Oxygen release simply doesn't support Jigsaw. Your best bet is to stay on Photon while you try to figure this out. As a Maven project, shouldn't you be setting compiler versions in the pom.xml?
  • @nitind pom.xml sets the compiier to 10, but you can overwrite this in the Eclipse build preferences.
  • Stephan - can you bring your question to to jigsaw-dev?
  • Thanks, I guess I will need to exclude some transitive dependencies then (or update more libraries).
  • Great answer. Would you consider writing a follow-up explaining the specific procedure to be followed, using the new UI, for someone that does not understand the precise rules of modular compilation? (I am thinking of students of mine learning Java, I can’t teach them all the complexity of Java in one go but still would like to expose them to interesting projects as soon as possible, where they might face this difficulty.)
  • @OlivierCailloux Buried in the Eclipse bug report thread at comment 51 are these short instructions that worked for me: "To exclude xml-apis.jar, open your POM in eclipse, go to the Dependency Hierarchy tab, filter by xml-api, right-click on any instance of xml-apis that appears, and choose Exclude Maven Artifact."
  • Third solution: exclude xml.apis from the project dependencies. Drawbacks compared to excluding java.xml from the set of observable modules: 1) the dependency that introduced xml.apis as a transitive dependency (xerces, in my case) might work well with that specific version and misbehave with the one provided with the JRE (which might be older); 2) xml.apis might provide classes not included in the version provided with the JRE. But, similar risks exist with excluding the java.xml module (on which other components might depend). @StephanHerrmann: any thoughts?
  • Plus, xml.apis:xml.apis:1.4.01 seems to be a subset of java.xml (as provided in OpenJDK 11): I found no class included in the former missing in the latter, except for org.apache.xmlcommons.Version, but conversely, many classes from java.xml are not in xml.apis. Thus I’d rather recommend to exclude xml.apis and keep the JRE module.
  • unfortunately with the new eclipse version 2019-06, it is not possible anymore to change the order to resolve the issue