You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署CXF JAX-WS Web Service时出现JBoss错误该如何解决

错误原因分析

核心错误为Spring核心类org.springframework.context.ApplicationContextException找不到,根因如下:

  • 该类属于spring-context依赖包,当前pom仅引入spring-web,传递依赖的spring-context可能因依赖解析问题未被打入war包
  • 错误将Maven插件(wildfly-maven-plugin、maven-war-plugin)声明在全局<dependencies>节点,干扰正常依赖解析逻辑
  • WildFly内置Spring模块的类加载优先级高于应用包内依赖,引发类加载冲突

可行解决方案

1. 修正pom.xml配置

  • 删除<dependencies>节点下的两个插件依赖,插件仅需保留在<build><pluginManagement><plugins>节点即可,无需声明为全局依赖
  • 显式引入spring-context依赖,避免传递依赖缺失:
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.2.15.RELEASE</version>
</dependency>
  • 确认所有Spring、CXF相关依赖没有设置provided scope,使用默认compile scope,保证依赖被打入WAR包的WEB-INF/lib目录

2. 优化JBoss部署配置

更新jboss-deployment-structure.xml,排除WildFly内置Spring模块,避免类加载冲突:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
        <exclude-subsystems>
            <subsystem name="webservices" />
        </exclude-subsystems>
        <exclusions>
            <module name="org.springframework" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

3. 重新执行部署命令

执行以下命令清理历史产物、重新打包并部署:

mvn clean package wildfly:deploy

验证方式

部署前可以解压本地构建好的WAR包,检查WEB-INF/lib目录下是否存在spring-context-5.2.15.RELEASE.jar,存在则说明依赖打包正常。

内容的提问来源于stack exchange,提问作者TSSK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 13:24:04