7

In Java 8, I've been using these packages:

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;

Now, in Java 10, they cannot be resolved. What Maven dependency should I include? I don't want to use modules.

enter image description here

enter image description here

Solution:

Exclude old Maven dependencies stax-api and xml-apis from old libraries.

Xdg
  • 1,735
  • 2
  • 27
  • 42
  • They should resolve, unless you've accidentally declared a module. Maybe your IDE added one automatically? – teppic May 07 '18 at 09:44
  • I'm using Eclipse and they don't resolve. Similar problem was with javax.xml.bind, for that I've added Maven dependencies jaxb-*. – Xdg May 07 '18 at 10:01
  • 1
    javax.xml.bind is a different problem - it's deprecated and not available by default. java.xml will be available automatically _unless_ you've declared a module (is there a "module-info.java" file in your source path?). – teppic May 07 '18 at 10:12
  • 1
    It would be useful to past in the error message that are you seeing. – Alan Bateman May 07 '18 at 10:29
  • Error is standard class (import) not found. Using default Eclipse settings. I will write details when I get to computer. – Xdg May 07 '18 at 14:23
  • Are you running in an OSGi environment? The packages you mention have been moved into new Java modules and if you're running inside an osgi container, these packages may no longer be available from the framework. – gjoranv May 07 '18 at 14:51
  • I've added some images. In which module are my missing packages? If I cannot resolve it with maven dependency, I will include proper package and that's it. – Xdg May 07 '18 at 19:18
  • Module is java.xml (https://docs.oracle.com/javase/9/docs/api/javax/xml/stream/XMLInputFactory.html). Problem were some Maven dependencies from old libraries - `xml-apis` and `stax-api`. I've excluded them and all is okay. – Xdg May 08 '18 at 06:26
  • This sounds like an Eclipse issue. If you deploy an ancient JAR file with javax.xml.stream.* APIs on the class path then Eclipse should ignore them as javax.xml.stream is exported by the java.xml module. – Alan Bateman May 08 '18 at 07:14
  • I'm having the same issue and deleting old xml dependencies didn't help – Rodrigo R. Coelho Jul 16 '19 at 18:27

1 Answers1

0

I removed the stax-api dependency from the pom.xml file and the issue is gone.

dmatej
  • 1,518
  • 15
  • 24