【问题标题】:Springboot Wildfly 10 deployment error jdk.unsupported module not foundSpringboot Wildfly 10 部署报错 jdk.unsupported module not found
【发布时间】:2021-03-13 23:45:36
【问题描述】:

我有一个使用 Java 1.8 的 Springboot v2 项目,当我尝试在 Wildfly 10 上部署我的 springboot 项目时,我不断收到此错误

19:12:25,295 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "HealthCheck.war")]) - failure description: {
    "WFLYCTL0080: Failed services" => {"jboss.module.service.\"deployment.HealthCheck.war\".main" => "org.jboss.msc.service.StartException in service jboss.module.service.\"deployment.HealthCheck.war\".main: WFLYSRV0179: Failed to load module: deployment.HealthCheck.war:main
    Caused by: org.jboss.modules.ModuleNotFoundException: jdk.unsupported:main"},
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.module.service.\"deployment.HealthCheck.war\".main"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined

我已经创建了一个 jboss-deployment-structure.xml 并在那里添加了“jdk.unsupported”依赖项,我还尝试将其添加到 MANIFEST.MF 并且我还尝试添加缺少的“jdk.unsupported”依赖maven-war插件下的pom文件但没有运气。

【问题讨论】:

  • WildFly 10 中没有模块jdk.unsupported。您是否创建了该模块?
  • 没有。我相信它是在 Java 9 上引入的。我使用的是 Java 8,所以我不确定代码的哪一部分正在寻找它。
  • 该异常来自 JBoss 模块,因此它正在尝试加载该模块。您确定您使用的是 WildFly 10 吗?如果您有一个不正确的模块的 jboss-deployment-structure.xmlMANIFEST.MF 条目。

标签: java spring-boot maven wildfly wildfly-10


【解决方案1】:

这是由于breaking change,它在Spring-core 5.3.*中引入,导致上述问题的Spring-core库中的更改是commit。如果您使用 Spring boot 版本2.4.*,那么您肯定会遇到这个问题,因为它会拉取 Spring-core 5.3.* 的传递依赖。务实的做法是要么升级wildfly版本(最新版本是22.0.1.Finalwildfly 10.1.0.Final 已于 2016 年 8 月 19 日发布近 5 年)或将您的 Spring Boot 版本降级为'2.3.*.RELEASE'


解决方法 对于无法升级 Wildfly 服务器但使用最新 Spring 版本的情况(5.3.*),请按照以下解决方法。实际问题是 Spring-core 5.3.x 包含 MANIFEST.MF 文件条目 Dependencies: jdk.unsupported。如果我们从 jar 的 MANIFEST.MF 文件中删除特定条目,我们可以在 Wildfly 10.X 版本本身中使用 Spring-core 5.3.x。

要修补 5.3.x 并将其拉入类路径,需要执行以下步骤:

  1. 作为 jar 文件本身,存档使用7-Zip/winrar 或任何文件存档实用工具打开它。打开MANIFEST.MF 并删除最后一行Dependencies: jdk.unsupported 并保存更改。
  2. 将修补后的 jar 文件放入您的项目文件夹,即lib
  3. 在项目级别排除Spring-core 5.3.x 并强制构建工具使用项目目录中的Spring-core 5.3.x 修补库并将其添加到您的类路径中。我为gradle 用户提供了sn-p
dependencies {
    //Adding the patched jar into the classpath from a project directory
    compile files('lib/spring-core-5.3.3.jar')
}

configurations.all {
    //Excluding the spring-core-5.3.3.jar at the project level
    exclude group: 'org.springframework', module: 'spring-core'
}

【讨论】:

  • 您的回答帮助了我一个月的问题。有效。 +1
  • @XsoluteIm,我添加了用于我的项目的解决方法
  • 除非我使用 maven 进行项目,否则您的解决方法帮助很大,谢谢!
  • 我在使用 maven 时遇到了另一个错误,但使用 gradle 很容易成功。非常感谢!
【解决方案2】:

我找到了一个更好的解决方案,基于在 jboss 或 wildfly 上创建一个名为 jdk.unsupported 的新假模块。

就我而言,我无法升级 JBoss EAP 7.1,我想保持更新到最新版本的 Spring。

所以我所做的是在 modules/system/layers/base 文件夹下创建一个新的假模块,它就像一个魅力!

【讨论】:

  • 你能描述一下你是怎么做到的吗?
  • 您应该为 JBoss 创建一个新模块。这很容易做到。 1. 在 $JBOSS_PATH/modules/system/layers/base 下创建一个名为 jdk/unsupported/main 的新文件夹 2. 在 main 下创建一个新文件 文件夹名为 module.xml,内容如下: ´´´´ ´´´´
  • 非常感谢,这是一个很好且简单的解决方案,可确保应用程序与旧 JBoss 版本兼容。
【解决方案3】:

我遇到了完全相同的问题,并通过使用 java 8 将 wildfly 10 升级到 20 来解决它。 我的 Spring Boot 版本是 2.4.0 或者,我将我的 Spring Boot 版本降级为 1.5.8.RELEASE,并能够在 Wildfly 10 上成功运行。

【讨论】:

    猜你喜欢
    • 2018-07-19
    • 1970-01-01
    • 1970-01-01
    • 2018-10-22
    • 2017-09-13
    • 1970-01-01
    • 2018-04-12
    • 2017-09-13
    • 1970-01-01
    相关资源
    最近更新 更多