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

WildFly 26 Bootable Jar部署EAR时依赖缺失启动失败排查

WildFly Bootable Jar构建EAR时模块依赖启动失败排查

我有一个可正常部署在WildFly 26上的EAR包,希望使用wildfly-jar-maven-plugin为其构建Bootable Jar。已配置WF26的Feature Pack、多个Layers,以及用于配置数据源的CLI脚本,但启动时出现模块依赖缺失导致的失败(直接部署EAR可正常运行)。

Maven配置

<profile>
    <id>build-bootable-jar</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-jar-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <display-cli-scripts-output>true</display-cli-scripts-output>
                    <feature-packs>
                        <feature-pack>
                            <location>wildfly@maven(org.jboss.universe:community-universe)#${wildfly.version}</location>
                        </feature-pack>
                    </feature-packs>
                    <layers>
                        <layer>ejb</layer>
                        <layer>bean-validation</layer>
                        <layer>cdi</layer>
                        <layer>ee-security</layer>
                        <layer>jaxrs</layer>
                        <layer>messaging-activemq</layer>
                        <layer>jpa</layer>
                        <layer>observability</layer>
                        <layer>resource-adapters</layer>
                        <layer>transactions</layer>
                        <layer>web-server</layer>
                        <layer>jsonb</layer>
                        <layer>naming</layer>
                        <layer>jaxrs-server</layer>
                    </layers>
                    <cli-sessions>
                        <cli-session>
                            <properties-file>
                                ../project.properties
                            </properties-file>
                            <script-files>
                                <script>src/main/bootable/bootable.cli</script>
                            </script-files>
                        </cli-session>
                    </cli-sessions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>
<profile>
    <id>run-bootable-jar</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-jar-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

错误日志

14:34:50,978 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "ioserver-ear.ear")]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => [
        "module.resolved.service.\"deployment.ioserver-ear.ear.export-newcore.jar\".main",
        "module.resolved.service.\"deployment.ioserver-ear.ear.import-entity.jar\".main",
        ...
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
    "jboss.module.service.\"deployment.ioserver-ear.ear.license-server.jar\".main is missing [module.resolved.service.\"deployment.ioserver-ear.ear.license-server.jar\".main]",
    "jboss.module.resolve.phase.\"deployment.ioserver-ear.ear.arrangement.jar\".main.2 is missing [jboss.module.spec.service.\"deployment.ioserver.ear.export.jar\".main, jboss.module.spec.service.\"on.jar\".main, jboss.module.spec.service.\"deployment.ioserver.ear.db.jar\".main, jboss.module.spec.service.\"deployment.ioserver.ear.entity.jar\".main, jboss.module.spec.service.\"deployment.ioserver.ear.entityejb3.jar\".main, jboss.module.spec.service.\"deployment.ioserver.ear.payroll-export.jar\".main]",
    ...

日志中存在模块依赖自身的异常:

"jboss.module.service.\"deployment.ioserver-ear.ear.ons-api.war\".main is missing [module.resolved.service.\"deployment.ioserver-ear.ear.ons-api.war\".main]",

EAR结构

> tree
.
|____import.jar
|____...
|____code.jar
|____import-entity.jar
|____...
|____report.jar
|____export-newcore.jar
|____...
|____META-INF
| |____application.xml
| |____jboss-deployment-structure.xml
|____lib
| |____perfmark-api-0.26.0.jar
| |____api-grpc-3.0.jar
| |____...

补充信息

  • 存在多条Class Path entry ... does not point to a valid jar for a Class-Path reference警告,第三方Jar包含Class-Path条目,自有Jar无此类条目
  • standalone/tmp/war目录为空,Jar文件存在于standalone/tmp/vfs/deployment/deploymentXXX/但其内容目录为空
  • 启用部署日志后可见模块已部署,调试WildFly可见模块描述符已创建,但多数缺失信息为模块依赖自身

排查方向建议

  • 添加EAR核心Layer:当前配置的Layers中未包含ear层,Bootable Jar默认不会自动启用EAR部署支持,需在<layers>中添加<layer>ear</layer>,这是处理EAR结构的关键
  • 清理构建缓存:删除项目target目录下的wildfly-jar-build文件夹,重新执行构建命令,避免旧的缓存部署结构干扰
  • 检查jboss-deployment-structure.xml:确认文件内的模块依赖、导出导入配置是否正确,尤其是是否存在循环依赖或引用不存在的模块,Bootable Jar的模块解析逻辑与传统部署可能存在差异
  • 修复第三方Jar的Class-Path问题:第三方Jar的无效Class-Path条目可能导致VFS无法正确解析模块,可通过maven-jar-plugin在构建时移除这些Jar的Manifest中的Class-Path属性,或者替换为不包含无效路径的版本
  • 启用详细部署日志:启动Bootable Jar时添加JVM参数:-Dorg.jboss.as.logging.per-deployment=false -Dlogging.level.org.jboss.as.server.deployment=DEBUG,获取模块解析的详细过程,定位具体失败的模块
  • 验证模块依赖关系:使用jboss-modules工具分析EAR内各Jar的依赖树,确认是否有隐式依赖未被Bootable Jar的模块系统识别,必要时通过jboss-deployment-structure.xml显式声明依赖
  • 对比类加载策略差异:Bootable Jar使用精简的模块系统,与传统WildFly的类加载策略不同,检查是否有依赖的系统模块未被包含在所选Layers中,可通过wildfly-jar-maven-plugin的<layers>添加缺失的系统模块层

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 22:17:02