LogBack的日志报错解决办法 org.xml.sax.SAXNotRecognizedException

报错信息如下:

复制代码
18:00:57,395 |-ERROR in ch.qos.logback.core.joran.event.SaxEventRecorder@48aaecc3 - Error during parser creation or parser configuration org.xml.sax.SAXNotRecognizedException: unrecognized feature http://xml.org/sax/features/external-general-entities
   at org.xml.sax.SAXNotRecognizedException: unrecognized feature http://xml.org/sax/features/external-general-entities
   at 	at org.gjt.xpp.sax2.Driver.setFeature(Driver.java:178)
   at 	at org.gjt.xpp.jaxp11.SAXParserImpl.setFeatures(SAXParserImpl.java:149)
   at 	at org.gjt.xpp.jaxp11.SAXParserImpl.<init>(SAXParserImpl.java:132)
   at 	at org.gjt.xpp.jaxp11.SAXParserFactoryImpl.newSAXParserImpl(SAXParserFactoryImpl.java:114)
   at 	at org.gjt.xpp.jaxp11.SAXParserFactoryImpl.setFeature(SAXParserFactoryImpl.java:142)
   at 	at ch.qos.logback.core.joran.event.SaxEventRecorder.buildSaxParser(SaxEventRecorder.java:88)
   at 	at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:62)
   at 	at  

原因分析:

  • 从报错日志可以看出是logback的xml日志解析出现问题, 报错相关的类是 org.gjt.xpp.sax2.等相关的类
  • 查找这些类所在的包为 pull-parser , 并且这个包的最新版本都是2005年的,都没有维护
  • 我并没有直接引入这个包, 继续查找发现是阿里云的SDK引入的老版本的dom4j包, dom4j再引入这个包导致的问题。
  • SDK被其他项目使用,最好做到少依赖,不依赖第三方包和过期包。 垃圾阿里云

解决办法

  1. 现在阿里云的SDK访问的接口也全部都是application/json的格式了, 并且我也没有使用到xml格式
  2. 我尝试直接排除依赖 pull-parser, 启动项目成功, 运行后也正常。
  3. 阿里对外提供的SDK真的是垃圾, 基本的依赖都没有清理好
相关推荐
IT_Octopus3 天前
一次由 RestTemplate 引发的 Connection reset:被 XML 截胡的请求体
xml·java·spring boot
Dontla3 天前
网站爬虫控制策略介绍(robots.txt、sitemap.xml、x-robots-tag、noindex、nofollow)网站索引
xml·爬虫·dubbo
.柒宇.3 天前
ELK日志分析系统实战指南:Elasticsearch搭建与入门(8.18.8版本)
运维·elk·elasticsearch·logback·日志系统
风起洛阳@不良使4 天前
spring中xml和注解开发的对比
xml·java·spring
hdsoft_huge4 天前
SpringBoot系列17:日志体系Logback配置,日志分割、脱敏、异常堆栈收集规范(生产级落地)
java·spring boot·logback
Mikowoo0075 天前
批量汇总XML格式的发票信息
xml·python
倒流时光三十年5 天前
Logback 系列(13):生产环境配置建议清单
logback
倒流时光三十年5 天前
Logback 系列(12):高级篇 · MDC 链路追踪
logback
逃逸线LOF5 天前
xml文件如何加载properties文件(spring容器加载properties文件)
xml
倒流时光三十年6 天前
Logback 系列(3):三大核心组件 Logger / Appender / Encoder
java·开发语言·logback