Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.xml.sax.SAXNotRecognizedException 能帮我看看这是什么原因导致的吗?折腾了3天了,再不行弃坑了 #2054

Closed
shijia2118 opened this issue Aug 27, 2021 · 11 comments
Labels
development completed Development completed, waiting for release help wanted Extra attention is needed pending verification This problem needs to be confirmed

Comments

@shijia2118
Copy link

异常代码
1.MainActivity.java核心代码截图:
image
上述的path测试过,没有问题.demo.xlsx是存在手机上的测试文件,内容与easyexcel库中的demo.xlsx一致.
2.上述的DemoData和DemoDataListener也是与库demo中内容一致.

报错内容
image

项目依赖
image

@shijia2118 shijia2118 added the help wanted Extra attention is needed label Aug 27, 2021
@jobsLee-lcj
Copy link

遇到同样的问题,原因是http://apache.org/xml/features/disallow-doctype-decl 这个链接404了,这个feature是用来设置禁用DTD的,即不允许将外部实体包含在传入的 XML 文档中,从而防止XML实体注入。
image

但是,很遗憾,我也不知道该怎么fix 😭

@zhuangjiaju zhuangjiaju added the pending verification This problem needs to be confirmed label Sep 14, 2021
@gotoorder
Copy link

Android端要跑起来真难啊

@AlexJialene
Copy link

我也有遇到这个问题。
java环境1.8
报错:

org.xml.sax.SAXNotRecognizedException: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized.

推测是xml解析器加载错了。具体未深究
增加依赖(gradle):

compile group: 'xerces', name: 'xercesImpl', version: '2.11.0'

参考链接: https://www.jianshu.com/p/70427180eaf0

@VamChao
Copy link

VamChao commented Dec 29, 2021

有人解决吗?

@ZhaoLuChen
Copy link

我也遇到了这个问题,解决不了打算用POI试试,在群里请教了一下大佬说POI也有坑,因为Java和安卓的一个基础类实现方式不一样。

@zly1024
Copy link

zly1024 commented Mar 22, 2022

大佬,我也遇到一样的了,之前跑着没问题,今天一看报这个错了

@zly1024
Copy link

zly1024 commented Mar 22, 2022

解决了吗

@xworks
Copy link

xworks commented Apr 3, 2022

@lichuanjun @gotoorder @AlexJialene @VamChao @zhuangjiaju

克隆了一份代码,将这个feature异常包了起来

           try {
                saxFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
            } catch (SAXNotRecognizedException e) {
                log.warn(
                    "SAXNotRecognizedException occur, not supported feature: " +
                        "http://apache.org/xml/features/disallow-doctype-decl, which will disable DOCTYPE declaration" +
                        " if set true.");
            }

在Android项目里以jar包形式引入自己编译的easyexcel包,在gradle文件里面引入以下依赖:

implementation 'org.apache.poi:poi:4.1.2'
implementation 'org.apache.poi:poi-ooxml:4.1.2'
implementation 'org.apache.poi:poi-ooxml-schemas:4.1.2'
implementation 'org.apache.commons:commons-csv:1.8'
implementation 'cglib:cglib:3.3.0'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'org.ehcache:ehcache:3.8.1'
implementation 'javax.xml.stream:stax-api:1.0'

以上在
compileSdk 31
minSdk 26
targetSdk 31
条件下测试可用,其他没有测试过。

上面代码的fork地址:https://github.com/xworks/easyexcel

@zhuangjiaju zhuangjiaju added the development completed Development completed, waiting for release label May 10, 2022
@zhuangjiaju
Copy link
Collaborator

该问题已经在3.1.0+版本里面解决,最新版本:Maven central

@xichunjie
Copy link

@lichuanjun @gotoorder @AlexJialene @VamChao @zhuangjiaju

克隆了一份代码,将这个feature异常包了起来

           try {
                saxFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
            } catch (SAXNotRecognizedException e) {
                log.warn(
                    "SAXNotRecognizedException occur, not supported feature: " +
                        "http://apache.org/xml/features/disallow-doctype-decl, which will disable DOCTYPE declaration" +
                        " if set true.");
            }

在Android项目里以jar包形式引入自己编译的easyexcel包,在gradle文件里面引入以下依赖:

implementation 'org.apache.poi:poi:4.1.2'
implementation 'org.apache.poi:poi-ooxml:4.1.2'
implementation 'org.apache.poi:poi-ooxml-schemas:4.1.2'
implementation 'org.apache.commons:commons-csv:1.8'
implementation 'cglib:cglib:3.3.0'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'org.ehcache:ehcache:3.8.1'
implementation 'javax.xml.stream:stax-api:1.0'

以上在 compileSdk 31 minSdk 26 targetSdk 31 条件下测试可用,其他没有测试过。

上面代码的fork地址:https://github.com/xworks/easyexcel

大佬,为啥你把你的代码拷下来还是用不了呢,报com.alibaba.excel.exception.ExcelGenerateException: java.lang.ExceptionInInitializerError这个错

@zhudasen
Copy link

大佬,确实有效 跑着没问题吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development completed Development completed, waiting for release help wanted Extra attention is needed pending verification This problem needs to be confirmed
Projects
None yet
Development

No branches or pull requests