Jersey 2 project and Karyon admin #56

Closed
ghost opened this Issue Sep 25, 2013 · 7 comments

Projects

None yet

2 participants

@ghost
ghost commented Sep 25, 2013

My project is built with Jersey 2.3, when I try to use Karyon admin, I get the error below and the app won't start properly. It seems that it was caused by a conflict between jax-rs api 1 and 2.

(If I keep jsr311-api-1.1.1 or any jar containing jaxrs-1.x API, my Jersey 2 project wouldn't work, and if I keep only javax.ws.rs-api-2.0.jar, Kayron admin wouldn't start. Both version of jax-rs API has javax.ws.rs.core.UriBuilder.class)

Do you guys know of any way to work around this problem?

    2013-09-25 13:47:15,764 WARN [qtp791589140-42] o.e.j.s.ServletHandler [ServletHandler.java:539] Error for /admin
    java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
        at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119) ~[javax.ws.rs-api-2.0.jar:2.0]
        at com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:879) ~[jersey-bundle-1.9.1.jar:1.9.1]
        at com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:843) ~[jersey-bundle-1.9.1.jar:1.9.1]
        at com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:804) ~[jersey-bundle-1.9.1.jar:1.9.1]
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300) ~[jetty-servlet-7.6.7.v20120910.jar:7.6.7.v20120910]
        at com.netflix.adminresources.RedirectFilter.doFilter(RedirectFilter.java:54) ~[karyon-admin-1.0.20.jar:na]
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300) ~[jetty-servlet-7.6.7.v20120910.jar:7.6.7.v20120910]
        at com.netflix.adminresources.LoggingFilter.doFilter(LoggingFilter.java:64) ~[karyon-admin-1.0.20.jar:na]
        ...
@NiteshKant
Contributor

Since its an incompatible change in the API, the only way I could see it is by loading one of them in a different classloader but it will be difficult to do.

@ghost
ghost commented Sep 26, 2013

Thanks for your response and suggestion.

I looked at Jersey's code. The problem is simply because jax-rs 2.0 added several (not-so-important) abstract methods which are not overridden in Jersey 1.x's implementation classes. So for testing purpose, I built a custom jersey jar with those 'missing' methods implemented, and then everything worked! Of course, there potentially could be many other incompatibilities, but anyway, I haven't faced any so far.

The methods I added are: com.sun.jersey.api.uri.UriBuilderImpl.class -> public UriBuilder uri(String str) and com.sun.jersey.core.spi.factory.public.ResponseImpl.class -> public StatusType getStatusInfo(). Both file are in jersey-core (also jersey-bundle) jar.

@ghost
ghost commented Sep 27, 2013

I'm facing a new problem. I found some Jersey 1.x classes (like com.sun.jersey.core.spi.factory.public.ResponseBuilderImpl) are actually registered instead of Jersey 2.x class, and therefore messed up the Jersey 2 app. Also there are more methods need to be 'overriden'...
Looks like mixing Jersey 1 and 2 in the same classloader is not a good idea. I think I'll disable Karyon admin for now.

@NiteshKant
Contributor

makes sense to me.

On Thu, Sep 26, 2013 at 7:47 PM, su- notifications@github.com wrote:

I'm facing a new problem. I found some Jersey 1.x classes (like
com.sun.jersey.core.spi.factory.public.ResponseBuilderImpl) are actually
registered instead of Jersey 2.x class, and therefore messed up the Jersey
2 app. Looks like mixing Jersey 1 and 2 in the same classloader is not a
good idea. I think I'll disable Karyon admin for now.


Reply to this email directly or view it on GitHubhttps://github.com/Netflix/karyon/issues/56#issuecomment-25218971
.

@NiteshKant
Contributor

I am closing this issue as this requires moving karyon admin to jersey 2.0 which is not in the plan & does not add value.

@NiteshKant NiteshKant closed this Nov 19, 2013
@majikthys

@NiteshKant is it on the timeline to upgrade karyon to jax-rs 2.0 / jersey 2.x? We see a lot of value in 2.0, especially around the new filters and interceptors.

@NiteshKant
Contributor

@majikthys no that isn't in the timeline specifically for the karyon-admin package.
I am working on karyon 2.0 which introduces more runtime aspects to karyon in which I will be glad if you want to add jersey 2.x support. Since, inside netflix we do not have any usage for jersey 2.x, it is low priority for me.

@jingjingwang jingjingwang referenced this issue in uwescience/myria Dec 3, 2014
@jingjingwang jingjingwang Completely remove Jersey 1 from classpath.
When there were multiple versions of Jersey, Java Classloader might pick the wrong one for a certain class name.
003d9a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment