久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 java-8 “secure-processing org.xml.sax.SAXNotRecognizedE

Error unmarshalling xml in java-8 quot;secure-processing org.xml.sax.SAXNotRecognizedException causing java.lang.IllegalStateExceptionquot;(在 java-8 “secure-processing org.xml.sax.SAXNotRecognizedException 導(dǎo)致 java.lang.IllegalStateEx
本文介紹了在 java-8 “secure-processing org.xml.sax.SAXNotRecognizedException 導(dǎo)致 java.lang.IllegalStateException"中解組 xml 時(shí)出錯(cuò)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

以下代碼在 Java 7 中運(yùn)行良好

The following code worked fine in Java 7

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

String xmlString = '<xml ..... ';

StringReader reader = new StringReader(xmlString);

JAXBContext jc = JAXBContext.newInstance(MyClass.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
MyClass myClass = (MyClass) unmarshaller.unmarshal(reader);
....

現(xiàn)在我們必須升級(jí)到 Java 8,現(xiàn)在執(zhí)行代碼時(shí)出現(xiàn)此異常:

Now we had to upgrade to Java 8 and now I get this exception when executing the code:

Sep 03, 2014 1:42:47 PM com.sun.xml.internal.bind.v2.util.XmlFactory createParserFactory
SCHWERWIEGEND: null
org.xml.sax.SAXNotRecognizedException: Feature: http://javax.xml.XMLConstants/feature/secure-processing
    at org.apache.xerces.jaxp.SAXParserFactoryImpl.setFeature(SAXParserFactoryImpl.java:100)
    at com.sun.xml.internal.bind.v2.util.XmlFactory.createParserFactory(XmlFactory.java:114)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.getXMLReader(UnmarshallerImpl.java:139)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:214)

我知道有一個(gè)問(wèn)題 針對(duì)類似的問(wèn)題,但退回到 java 7 對(duì)我來(lái)說(shuō)不是解決方案.

I know that there is a question targeting a similar problem, but stepping back to java 7 is not a solution for me.

我嘗試添加以下maven依賴

I tried to add the following maven dependency

<dependency>
    <groupId>javax.xml</groupId>
    <artifactId>jaxp-api</artifactId>
    <version>1.4</version>
</dependency>

但這并沒(méi)有改變結(jié)果,所以我刪除了它(感謝@BlaiseDoughan 提供的信息,它包含在 Java 6 中)

but that did not change the result, so I removed it (thanks to @BlaiseDoughan for the information, that this is included in Java 6)

歡迎任何提示,非常感謝.

Any hints are welcome, many thanks.

推薦答案

這是一個(gè)依賴問(wèn)題.

這是我解決問(wèn)題的方法:

Here is my way how I solved the problem:

  1. 創(chuàng)建一個(gè)新的 maven 項(xiàng)目,使用我在下面附加的那段簡(jiǎn)單的代碼,程序正常崩潰并出現(xiàn)錯(cuò)誤,無(wú)法解析結(jié)構(gòu),這沒(méi)關(guān)系.
  2. 將你的依賴項(xiàng)復(fù)制到項(xiàng)目 pom.xml 中,現(xiàn)在程序應(yīng)該會(huì)崩潰(如上所述)

  1. Make a new maven project, with that simple pieces of code, I attached below, the programm crashed normally with an error, that the structure couldn't be parsed which is ok.
  2. Copy your dependencies into the project pom.xml, now the programm should crash (as described above)

不,你在你喜歡的方法(好猜測(cè),Bisection,1-by-1 ..)之后刪除依賴項(xiàng)以找到壞"依賴項(xiàng).也許有人有更好(更專業(yè))的方法,這個(gè)對(duì)我有用.

no you remove dependencies after your favoured method (good guessing, Bisection , 1-by-1 ..) to find the "bad" dependency. Maybe someone has a better (more professional) method, this one worked for me.

現(xiàn)在你可以決定要做什么了,也許有新版本可用,在我們的例子中,它是一個(gè)學(xué)院的自己的包,他包含一個(gè)學(xué)院的包,我可以排除.

now you can descide what to do, maybe a new version is available, in our case it was out own package of a colleage, where he included a package of a colleage, which i could exclude.

public class Test {
    public Test() {
    }
    public static void main(String[] args) {
        try {
            StringReader reader = new StringReader("<xml></xml>");
            JAXBContext jc = JAXBContext.newInstance(TestXML.class);
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            TestXML testXMLs = (TestXML) unmarshaller.unmarshal(reader);
        } catch (JAXBException e) {
            e.printStackTrace();
        }
    }
}

和 testXML 類

and the testXML class

@XmlRootElement(name="rss")
@XmlAccessorType(XmlAccessType.FIELD)
public class TestXML {   
    public TestXML() {
    }

    @XmlElementWrapper(name="channel")
    @XmlElement(name="item")
    private int i ;

    public int getI() {
        return i;
    }    
    public void setI(int i) {
        this.i = i;
    }
}

順便說(shuō)一句:在我的情況下是

BTW: In my case it was

<dependency>
    <groupId>jcs</groupId>
    <artifactId>jcs</artifactId>
    <version>1.3</version>
</dependency>

希望對(duì)您有所幫助.

這篇關(guān)于在 java-8 “secure-processing org.xml.sax.SAXNotRecognizedException 導(dǎo)致 java.lang.IllegalStateException"中解組 xml 時(shí)出錯(cuò)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Upload progress listener not fired (Google drive API)(上傳進(jìn)度偵聽(tīng)器未觸發(fā)(Google 驅(qū)動(dòng)器 API))
Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 將文件保存在特定文件夾中)
Google Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 無(wú)效的 DriveId 和 Null ResourceId)
Google drive api services account view uploaded files to google drive using java(谷歌驅(qū)動(dòng)api服務(wù)賬戶查看上傳文件到谷歌驅(qū)動(dòng)使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務(wù)帳號(hào)返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
主站蜘蛛池模板: 日本精品视频 | 国产精品免费福利 | 老牛嫩草一区二区三区av | 一区二区三区四区在线 | 免费av直接看| 精品91| 天天操夜夜拍 | 日一区二区三区 | 亚洲视频三区 | 久久99精品久久久久久 | 男人的天堂avav | 精品一区久久 | 国产中文字幕在线 | 亚洲精品视频一区二区三区 | 国产在线一区观看 | 亚洲精品高清视频 | 成人免费网站 | 美女露尿口视频 | 毛片久久久 | 午夜爽爽男女免费观看hd | 国产午夜精品一区二区三区嫩草 | 国产良家自拍 | 精品视频一区二区 | www.天天干.com | 午夜精品久久久久久久99黑人 | 伊人电影院av | 欧美视频 亚洲视频 | 国产成人精品久久 | 毛片网站免费观看 | 久久综合久色欧美综合狠狠 | 狠狠婷婷综合久久久久久妖精 | 自拍偷拍亚洲一区 | 国产中文字幕在线观看 | 精品国产一区二区在线 | 91原创视频 | www.9191.com| 请别相信他免费喜剧电影在线观看 | 国产精品mv在线观看 | 欧美黄色一区 | 欧美精品一区二区在线观看 | 四虎在线观看 |