Skip to content
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

Not able to create custom ResourceMethodDispatcherProvider in jersey >= 2.26 #5849

Open
kumaratulnitp opened this issue Jan 29, 2025 · 2 comments

Comments

@kumaratulnitp
Copy link

I have a code that used to work till jersey < 2.26 (before removal of hard wiring with HK2).
We were able to create a CustomResourceMethodDispatcherProvider (implements ResourceMethodDispatcher.Provider) and bind it via custom ResourceConfig and all rest calls would be dispatched by our own own dispatcher.

But this doesn't seem to work anymore. Tried a couple of options

  1. Changed the AbstractBinder import to jersey one,
  2. register a custom Feature, also tried registering custom provider via Feature but it didn't let me since it was trying to replace an internal class
  3. experiment with Provider annotation and web.xml.
  4. Extend RequestMethodDispatcherFactory and bind it.

None of the these worked. Upon code inspection, it looks like ApplicationHandler.java constructs ResourceMethodInvoker with internal class RequestMethodDispatcherFactory. And this Factory class instantiates only 2 internal providers (VoidVoidDispatcherProvider and JavaResourceMethodDispatcherProvider).

Is there a way to associate my custom ResourceMethodDispatcher and its Provider in jersey >= 2.26 ?

@jansupol
Copy link
Contributor

jansupol commented Feb 3, 2025

@kumaratulnitp Can you provide a simple reproducer that used to be working in 2.25?

@kumaratulnitp
Copy link
Author

Hi @jansupol, thanks for replying.
I have provided the simple use case in this stackoverflow question.

https://stackoverflow.com/questions/79390228/jersey-custom-provider-not-registered

Above code base doesn't register my custom dispatcher.
However, on changing the code base slightly (so that it runs on tomcat 9) - changed jakarta to javax, jersey 3.x to 2.25, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants