Service Loader does not work in Spring Boot
See original GitHub issueHi, definition Decoder and Encoder are not defined in the system.
private List<S> loadProviders() {
List<S> providers = new ArrayList<>();
ServiceLoader.load(service, Thread.currentThread().getContextClassLoader()).stream()
.forEach(p -> addProviderLenient(p, providers));
return Collections.unmodifiableList(providers);
}
change to “Thread.currentThread().getContextClassLoader()” solves the problem
System classLoader: Launched applications should use Thread.getContextClassLoader() when loading classes (most libraries and frameworks do so by default). Trying to load nested jar classes with ClassLoader.getSystemClassLoader() fails. java.util.Logging always uses the system classloader. For this reason, you should consider a different logging implementation.
locally tested, the problem disappeared
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
ServiceLoader do not work in packaged Spring Boot apps
I noticed that Java's ServiceLoader mechanism doesn't work in packaged Spring Boot apps. Background. I've tried to use javax.script.
Read more >ServiceLoader do not work in packaged Spring Boot apps
I noticed that Java's ServiceLoader mechanism doesn't work in packaged Spring Boot apps. Background. I've tried to use javax.script.
Read more >ServiceLoader: The Built in DI Framework You've Probably ...
ServiceLoader provides the capability to find and instantiate registered instances of interfaces or abstract classes. For those farmiliar with ...
Read more >Java Service Loader vs. Spring Factories Loader - DZone
In parallel to the Java Service Loader, Spring offers another Inversion of Control implementation. There's only a single property file involved, ...
Read more >Java Service Provider Interface | Baeldung
At the heart of the SPI is the ServiceLoader class. This has the role of discovering and loading implementations lazily.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@chadselph The fix is pending for the
1.7.0
release, which I’ll be able to finally cut this weekend.1.6.0
is still affected. In the meantime, you can pull in1.7.0-SNAPSHOT
as follows:I was also not sure about the ideality of this idea. For this reason, I didn’t make a pull request right away. I have a few days off from work in the near future. I will try to study this issue and conduct experiments. If anything happens, I will share the results and make a pull request