question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ServiceLocator can't find an implementation in common-pool workers

See original GitHub issue

Hi, I’ve noticed that we can’t read/create a token in a worker from ForkJoinPool.commonPool() in Spring’s uber-jar application because ServiceLocator can’t find an implementation for that (looks like there is a problem with context class loader related to the thread).

Example (it will throw UnavailableImplementationException for Serializer.class):

ForkJoinPool.commonPool()
        .execute(() -> Jwts.builder()
                .setClaims(Map.of(Claims.SUBJECT, "subject"))
                .compact());

Currently, I have a workaround to that by providing my own serializer (like this https://github.com/jwtk/jjwt#jackson-json-processor).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lhazlewoodcommented, Mar 11, 2020

I also want to say thank you to @timsazon for the sample project! That’s so helpful!

0reactions
bdemerscommented, Mar 11, 2020

@lhazlewood, I didn’t use a classloader, but I did mimic the “accessor” model that Classes uses. Let’s move the implementation discussion over to #574

(I just tested this out on @timsazon’s sample project)

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - ServiceLoader to find implementations of an interface
There are no built-in ways find all classes that implement a particular interface. Frameworks that can do something similar use their own classpath...
Read more >
Service Locator Pattern and Java Implementation - Baeldung
In this tutorial, we're going to learn about the Service Locator design pattern in Java. We'll describe the concept, implement an example ......
Read more >
Jersey 2.37 User Guide - GitHub Pages
This is user guide for Jersey 2.37. We are trying to keep it up to date as we add new features. When reading...
Read more >
Transforming U.S. Workforce Policies for the 21st Century
The publication of Transforming U.S. Workforce Development Policies for the 21st Century is the culmination of nearly two years of ...
Read more >
ForkJoinPool (Java Platform SE 8 ) - Oracle Help Center
A ForkJoinPool differs from other kinds of ExecutorService mainly by virtue of employing work-stealing: all threads in the pool attempt to find and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found