Error unmarshalling xml in java-8 “secure-processing org.xml.sax.SAXNotRecognizedException causing java.lang.IllegalStateException”

后端 未结 11 472
时光取名叫无心
时光取名叫无心 2020-12-05 00:21

The following code worked fine in Java 7

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

String          


        
11条回答
  •  一整个雨季
    2020-12-05 01:05

    Another possible solution to this is to add system variables:

    I used these in the maven tomcat plugin which worked for me:

    com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
    com.sun.org.apache.xerces.internal.parsers.SAXParser
    com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
    

    But you should also be able to set as follows:

    java -Dorg.xml.sax.parser="com.sun.org.apache.xerces.internal.parsers.SAXParser" \
    -Djavax.xml.parsers.DocumentBuilderFactory="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl" \
    -Djavax.xml.parsers.SAXParserFactory="com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"
    

    or even use System.setProperty:

    System.setProperty("org.xml.sax.driver", "com.sun.org.apache.xerces.internal.parsers.SAXParser");
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
    System.setProperty("javax.xml.parsers.SAXParserFactory","com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
    

提交回复
热议问题