ServiceLoader 返回 Wildfly-17.0.1 上的服务的空列表

发布于 2025-01-19 22:00:01 字数 774 浏览 3 评论 0原文

ServiceLoader<ConnectionLoader> serviceLoader = ServiceLoader.load(ConnectionLoader.class);

我的Web应用程序具有3个实现ConnectionLoader服务的实现,并且以上API在几乎所有Wieldfly-17.0.1之外的Web应用程序服务器上都可以正常工作。

Wildfly-17.0.1部署正在失败,上述API返回空列表。而且我无法理解为什么会发生这种情况。

我的系统配置是:

  • 操作系统:RHEL7.6
  • MSSQL SERVER 2019-192.168.25.105
  • JDK- ORACLE JDK 11

,我还验证了

  • 服务条目 ,在Meta-Inf/服务中,
  • 我可以使用反射加载类/实现服务。因此,它似乎不是类负载问题。
  • 但是,当我调用serviceloader.load(ConnectionLoader.Class,ConnectionLoader.Class.getClassLoader())时,它的工作正常非常好。即使这项工作我也无法更改约100秒服务的实现。并将第三方依赖性或代码块留在第三方罐子中。
  • 去年(使用JDK 1.8)使用的这种组合相同,我们不知道发生了什么变化以及为什么这个问题特定于这种组合。
ServiceLoader<ConnectionLoader> serviceLoader = ServiceLoader.load(ConnectionLoader.class);

My web application has 3 implementations of the ConnectionLoader service and the above API works perfectly fine on almost all the web application servers except Wildfly-17.0.1.

Wildfly-17.0.1 deployment is failing with the above API returning an empty list. And i am not able to understand why this is happening.

My system configuration is:

  • Operating System : RHEL7.6
  • MSSQL Server 2019 - 192.168.25.105
  • JDK - Oracle JDK 11

Also, I have verified that -

  • Service entries are present and correct inside the META-INF/services
  • I can load the class/implementation service using reflection. So it does not seems to be a ClassLoader issue.
  • But when I call the ServiceLoader.load(ConnectionLoader.class,ConnectionLoader.class.getClassLoader()) it works perfectly fine. Even though this works I cannot change the implementation for around 100s of services. And leave the 3rd party dependencies or code blocks in third-party jars.
  • This same combination used to work last year (with JDK 1.8) and we have no idea about what's changed and why this issue is specific to this combination.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文