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

Can't inject @Context to Blocking Jersey #213

Closed
schmitch opened this issue Apr 15, 2015 · 1 comment
Closed

Can't inject @Context to Blocking Jersey #213

schmitch opened this issue Apr 15, 2015 · 1 comment

Comments

@schmitch
Copy link
Contributor

Hello, on a "normal" Jersey container i could add additional context (like HttpHeaders) via the @Context.
But this fails in Karyon:

The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.lang.NoSuchMethodError: envisia.crm.jersey.resources.CustomerResource.getCustomer(I)Ljavax/ws/rs/core/Response;
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
    at netflix.karyon.jersey.blocking.JerseyBasedRouter$2.call(JerseyBasedRouter.java:63)
    at netflix.karyon.jersey.blocking.JerseyBasedRouter$2.call(JerseyBasedRouter.java:59)
    at rx.Observable$1.call(Observable.java:144)
    at rx.Observable$1.call(Observable.java:136)
    at rx.Observable.unsafeSubscribe(Observable.java:7495)
    at rx.internal.operators.OperatorSubscribeOn$1$1.call(OperatorSubscribeOn.java:62)
    at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Is there a possible workaround for that?
I would need to make a auth intercepter and pass a User variable into my controller. Currently the AuthIntercepter works, I just can't pass any values between Netty / Jersey and back.

@schmitch
Copy link
Contributor Author

Fixed it by correctly reloading everything.

Still have an problem by implementing this, since I could only integrate it either via RxNetty or via a JerseyFilter, it would be cool if there is some mechanisum to have both.

Somehow my solution would be a intermediate cache. So i have a DynamicFeature that injects User into my jersey container. User is here pulled from either my Cache or a remote service.

And then I have a RxNetty Intercepter that pulls the user from the remote service and puts it onto the cache. Also if user has not the correct rights it will reject it and either send an 401 or 403 response back via Observable.error.

A better and neat way would be to extend the HttpServerRequest and pass the user object as a property and then Inject it via javax.security.Prinicpals with a SecurityContext into the jersey container. but that would mean that i need to fork karyon2-jersey-blocking.

Currently RxNetty lacks of a session..

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

1 participant