colleagues! I have the issue above and already saw the article(-s) org.xml.sax.SAXNotRecognizedException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized with some ways of solution this problem but it doesn't help me.
I use maven and from main pom I have:
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.2</version>
</dependency>
I need it, because if I delete it than I have 'javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found'. The main goal is to add three property like ACCESS_EXTERNAL_DTD from javax.xml.XMLConstants but anyway I tried it wasn't successful.
I tried to:
Use System.property;
Use ClassLoader;
final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance("com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl", ClassLoader.getSystemClassLoader());
I had ClassCastException
java.lang.ClassCastException: class com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl cannot be cast to class javax.xml.parsers.SAXParserFactory
Use default instance:
final SAXParserFactory saxParserFactory = SAXParserFactory.newDefaultInstance(); But 'newDefaultInstance()' method wasn't recognized too.
Delete xerces dependency from main pom and use
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
to found DocumentBuilderFactoryImpl but it also wasn't success.