xml crashes when running on eclipse 06-2023 with Java 19
I have java19 and 20 installed on Eclipse 06-2023. I also installed maven with your pom.xml. Here are the issues. 1). Alexa.com disabled their service around 2021/2022. Thus the two alexa java files crash when running as java application regardless in run on maven setup or the JDT default Eclips 06-2023. 2). The following three files ReadXmlParser, ReadXmlParserLoop and ReadXmSaxParser2 will work in a Maven setup but will not run in a default JDT Eclipse 06-2023 setup with java 19 and all the java file dependencies imported one-by-one.
ReadXmlParser
Exception in thread "main" java.lang.IllegalArgumentException: InputStream cannot be null
at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:118)
at com.mkyong.xml.dom.ReadXmlDomParser.main(ReadXmlDomParser.java:36)
ReadXmlParserLoop
Exception in thread "main" java.lang.IllegalArgumentException: InputStream cannot be null
at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:118)
at com.mkyong.xml.dom.ReadXmlDomParserLoop.main(ReadXmlDomParserLoop.java:30)
ReadXmlSaxParser2
java.net.MalformedURLException: Cannot invoke "String.length()" because "spec" is null
at java.base/java.net.URL.<init>(URL.java:798)
at java.base/java.net.URL.<init>(URL.java:646)
at java.base/java.net.URL.<init>(URL.java:582)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:651)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:150)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:861)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
at com.mkyong.xml.sax.ReadXmlSaxParser2.main(ReadXmlSaxParser2.java:45)
Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "spec" is null
at java.base/java.net.URL.<init>(URL.java:704)
... 10 more
3). The ReadXmlSaxParserXXE will not run on a maven setup using your pom.xml file, nor on the defaul JDT Eclipse 06-2023 install.
Start Document
org.xml.sax.SAXParseException; systemId: file:///C:/Users/myinc/eclipse-workspace/Lang_Java/Java_Code/src/main/resources/staff-xxe.xml; lineNumber: 2; columnNumber: 10; DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:898)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:326)
at java.xml/javax.xml.parsers.SAXParser.parse(SAXParser.java:276)
at com.mkyong.xml.sax.ReadXmlSaxParserXXE.main(ReadXmlSaxParserXXE.java:32)
Other than this, the result of the java files will run on both the maven setup and the default JDT setup for Eclipse 06-2023. I'm still pretty new to Eclipse, and looking at these example files to see how these work.
For the case of ReadXmlSaxParserXXE, it imports javax.xml.parsers.... However, the dependencies files don't show the jar file associated with this. Moreover, my JDT imported jars also don't have this either. This may be the cause of this. It looks like maven has v2.0.2 now. The each of following versions all cause the other xml java files not to compile and "XXE" just crashes when installed then removed to test each of them out. xml-apis-1.0b2.jar xml-apis-1.4.01.jar xml-apis-2.0.2.jar from "central"