ServiceLoader 返回 Wildfly-17.0.1 上的服务的空列表
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论