From aae418653ee4b2514f5bbfe4193c286186a4e60c Mon Sep 17 00:00:00 2001 From: zhengwr Date: Fri, 26 Jun 2026 08:21:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(approval):=20WfTemplate=20XML=20=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E9=92=89=E5=88=B0=20JDK=20=E8=A7=A3=E6=9E=90=E5=99=A8?= =?UTF-8?q?,=E7=BB=95=E5=BC=80=20report=20=E5=B8=A6=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E4=B8=8A=E5=8F=A4=20xerces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit platform-report(jatools)依赖 com.dsasp.thirdparty:xerces:eip3(2004),被打进 platform-app fat jar 后,classpath 发现机制让 DocumentBuilderFactory.newInstance() 选中它;该古董不实现 JAXP 1.4 的 setFeature → AbstractMethodError,击穿 gateway 全部 WfTemplate XML 解析 (approval-meta 对任何带 formKey 的审批任务 500,影响 approve/reject 按钮解析+会签进度)。 修法:WfTemplateService.parseXml 显式指定 JDK 内置实现 com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl(总在,实现 setFeature), 不删/不动 report 的 xerces。极端兜底回退默认发现。 live:修复后 gateway approval-meta 正常返回 buttonsSource=wftemplate;会签进度 0/3→1/3 实时更新。 (另记:platform-metadata DataImportExcelParser 同样 newInstance(),数据导入路径同病,另案。) Co-Authored-By: Claude Opus 4.8 (1M context) --- .../flowgateway/aggregate/WfTemplateService.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/platform-flow-gateway/src/main/java/com/eip4/platform/flowgateway/aggregate/WfTemplateService.java b/platform-flow-gateway/src/main/java/com/eip4/platform/flowgateway/aggregate/WfTemplateService.java index ccdd8ad..5e452a8 100644 --- a/platform-flow-gateway/src/main/java/com/eip4/platform/flowgateway/aggregate/WfTemplateService.java +++ b/platform-flow-gateway/src/main/java/com/eip4/platform/flowgateway/aggregate/WfTemplateService.java @@ -110,10 +110,23 @@ public class WfTemplateService { } } + /** JAXP 1.4 兼容的 DocumentBuilderFactory:钉到 JDK 内置实现,绕开 platform-report(jatools)带入的 + * 上古 xerces-eip3.jar(2004) —— 后者不实现 setFeature(JAXP 1.4),classpath 发现机制选中它会致 + * AbstractMethodError,击穿 WfTemplate 全部 XML 解析。显式指定 JDK 实现类(总在),不删/不动 report 的 xerces。 */ + private static DocumentBuilderFactory newJdkDbf() { + try { + return DocumentBuilderFactory.newInstance( + "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", null); + } catch (Throwable t) { + // 极端兜底:JDK 实现类不可用时回退默认发现(正常 JDK 21 不会走到这) + return DocumentBuilderFactory.newInstance(); + } + } + /** DOM 解析模板 XML(禁 DOCTYPE/外部实体,防 XXE)。public 供单测直接验证解析(纯函数)。 */ public WfTemplateMeta parseXml(String xml) { try { - DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory f = newJdkDbf(); f.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); f.setFeature("http://xml.org/sax/features/external-general-entities", false); f.setFeature("http://xml.org/sax/features/external-parameter-entities", false);