-
Notifications
You must be signed in to change notification settings - Fork 357
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
Provider registered to Hk2InjectionManager cannot be process because of incompatible type #4092
Comments
Could you please provide following information: Jersey's version, piece of code which causes described exception (in this case reproducer would be ideal)? |
Have you tried to check
|
Bug appears when I'm sure this would be a quite common case (because Could be reproduced with this dropwizard project (jersey 2.28): https://gitlab.com/xvik/jersey-case
|
Unfortunately, since Jersey 2.26,
We try to fix this in 2.29. |
It would be great if injection api will go out of the intenal package (it's sad that it would mean another breaking change, but have to be done anyway). But I (and @ivanfryda) was mainly trying to pay your attention that ImmediateHk2InjectionManager.register(Object) is not correct: @Override
public void register(Object provider) {
if (isRegistrable(provider.getClass())) {
...
} it always performs
componentBag.getClasses(model -> ComponentBag.EXTERNAL_ONLY.test(model, injectionManager))
.forEach(injectionManager::register);
Class<?> providerClass =provider instanceof Class ? (Class) provider : provider.getClass();
if (isRegistrable(providerClass)) { |
@xvik Yes, we need to move a lot of classes out of internal packages when we define module.info, likely in 2.30 |
This is fixed by #4122 |
I'm configuring Jersey via the web.xml. On startup, I'm getting the following error:
java.lang.IllegalArgumentException: Provider registered to Hk2InjectionManager cannot be process because of incompatible type: class java.lang.Class. at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.register(ImmediateHk2InjectionManager.java:90)
What is going on is that CommonConfig.configureExternalObjects is getting the configured Class objects and these are sent to ImmediateHk2InjectionManager.register(Object). This method performs a providerClass.getClass(), which returns a plain Java Class object, which will not satisfy the condition for AbstractHk2InjectionManager.isRegistrable.
What is the solution to this?
The text was updated successfully, but these errors were encountered: