Spring从2.x升级至4.x后WebLogic部署触发java.lang.AbstractMethodError问题排查求助
这个java.lang.AbstractMethodError的核心原因是Spring Integration版本冲突,具体来说是你的项目同时混入了不兼容的旧版Spring Integration jar和新版Spring 4.x依赖,导致类加载时出现方法缺失。
具体冲突点
看你提供的lib目录,明显存在两套Spring Integration依赖:
- 过时的旧版本(1.0.3.RELEASE):
org.springframework.integration-1.0.3.RELEASE.jarorg.springframework.integration.jms-1.0.3.RELEASE-1.0.3.RELEASE.jarorg.springframework.integration.stream-1.0.3.RELEASE-1.0.3.RELEASE.jar
- 匹配Spring 4.x的新版本(4.3.17.RELEASE):
spring-integration-jms-4.3.17.RELEASE.jarspring-integration-stream-4.3.17.RELEASE.jarspring-integration-xml-4.3.17.RELEASE.jar
Spring Integration 1.0.3是和Spring 2.x配套的版本,完全不兼容Spring 4.x。当容器解析XML中的<si-xml:xpath-router>时,会尝试调用Spring Integration 4.x定义的AbstractRouterParser.parseRouter()方法,但旧版本的类根本没有实现这个方法,直接抛出AbstractMethodError。
分步解决
彻底清理旧版依赖
立即删除所有1.0.3版本的Spring Integration jar,这些旧jar是冲突的根源。补充缺失的核心依赖
你还缺少Spring Integration的核心jar:spring-integration-core-4.3.17.RELEASE.jar,必须添加它——所有Spring Integration模块都依赖这个核心包才能正常工作。统一Spring核心依赖版本
你的Spring beans(4.3.20)和context(4.3.18)版本略有差异,建议把所有Spring核心依赖(spring-beans、spring-context、spring-core、spring-oxm等)统一到同一个小版本(比如4.3.20.RELEASE),避免潜在的细微冲突。验证XML配置
你的XML配置已经使用了Spring Integration 4.3的schema(比如http://www.springframework.org/schema/integration/spring-integration-4.3.xsd),这部分是正确的,不需要修改。
验证修复
完成以上步骤后,重新打包EAR并部署到WebLogic,这个AbstractMethodError应该会消失。
内容的提问来源于stack exchange,提问作者user16334809

