-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error loading NumberSystem ServiceProvider with multiple ClassLoaders #383
Comments
Thanks, is there a scenario to replicate that, e.g. in an app server or other cases with multiple class loaders? |
ServiceLoader.load uses the context class loader. The context class loader usually is a child or identical to the class loader used as default. In Open Webstart the webstart application is loaded by its own class loader, which is not the default. The context class loader is set, but in the case of the application, that did bring me here, there are a lot of libraries involved. Which means some library somewhere is spawning a thread, which then tries to load (in the end) DefaultNumberSystem and fails to do so. In our case if you would not try only the context class loader, but also the loader of NumberSystem (NumberSystem.class.getClassLoader()) the issue would be resolved. |
Hey, so we have been stuck witth this problem for a while now, but have not had the time to make a PR. It's been a while since I've dealt with the issue, but I believe it only applies to the Gradle plugin (swagger-gradle), not the Maven plugin. As mentioned in the original post, the solution appears to be fairly simple, potential side effects notwithstanding. With this patch applied, Swagger/OpenAPI 3 is able to generate documentation and properly process annotations with Unit-based types.
|
This is applied, thanks @evanjs for the patch. Could everyone (also @addict3d, maybe @andi-huber) check it out in the 2.2-SNAPSHOT build of Indriya? |
@keilw indeed, the latest SNAPSHOT appears to work without issue, and I am able to generate OpenAPI documentation (with our project that depends on Indriya) utilizing the Swagger Gradle plugin Thank you! |
The Calculus class makes calls to ServiceLoader.load(NumberSystem.class) that will fail when using multiple ClassLoaders and Calculus.class is loaded using a ClassLoader other than the default ClassLoader. I suggest providing the additional ClassLoader argument that will use whatever ClassLoader actually loaded the Calculus class:
The text was updated successfully, but these errors were encountered: