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

Requiring JAX-RS 2.0 has knock-on effects #90

Closed
mcdee opened this issue Aug 29, 2016 · 23 comments
Closed

Requiring JAX-RS 2.0 has knock-on effects #90

mcdee opened this issue Aug 29, 2016 · 23 comments
Milestone

Comments

@mcdee
Copy link

mcdee commented Aug 29, 2016

Issue #82 has caused problems where Jackson can no longer be used with Jersey 1.x. Although Jersey 2.x is the current version 1.x is still very widely used. Could this change be considered for reversion?

@cowtowncoder
Copy link
Member

@mcdee This change was discussed on mailing list and there were no objections, so I don't think we would like reversion, at least not without further discussion.
Does code actually work if overriding Maven (or whatever build system you use) dependencies?
I do not remember if there are explicit references to JAX-RS 2 types.

Another angle here is that 2.7 is still JAX-RS 1.x compatible, and at some point we do need to move to JAX-RS 2.

@mcdee
Copy link
Author

mcdee commented Aug 29, 2016

At the least there is a reference to NoContentException at

return new NoContentException("No content (empty input stream)");
so we can't just fall back to an earlier version.

I'm using 2.7.7 for now.

@sappenin
Copy link

sappenin commented Sep 2, 2016

I'm also having this problem. If I upgrade to 2.8.x, I get a java.lang.NoClassDefFoundError for NoContentException. I'm using 2.7.7 for now as well.

@cowtowncoder
Copy link
Member

@sappenin That would mean that you are trying to run on JAX-RS 1.x container (or perhaps have duplicate jars in classpath, including one for 1.x)

@sappenin
Copy link

sappenin commented Sep 3, 2016

@cowtowncoder Yes, exactly - I'm running Jersey 1.19.x/JAX-RS 1.1.

@DigitalSmile
Copy link

I think, there should be definitely an option to use JAX-RS 1.x It is widely spread and I cannot see any reason why Jackson should be locked on JAX-RS 2.x only.

@cowtowncoder
Copy link
Member

This was discussed on dev list, and decision was made. If Jersey 1.x compatibility is needed, please use Jackson 2.7. If you do not like this, please bring it up on mailing lists; these issues are not debated or decided on issue tracker.

I will leave this issue open in case others find it, but there will be no action without significant re-evaluation by developers.

@DigitalSmile
Copy link

Thanks, for pointing it out.
I suppose I have found a thread, just leave the link here for next newcomers
https://groups.google.com/forum/#!topic/jackson-dev/-aGMJoV4R2U

@cowtowncoder
Copy link
Member

Thanks! Good idea to add the link too.

@Spikhalskiy
Copy link
Contributor

Spikhalskiy commented Oct 20, 2016

Absence of NoContentException is not the only problem

<init-param>
    <param-name>javax.ws.rs.Application</param-name>
    <param-value>com.pulsepoint.predict.web.JaxRsApplication</param-value>
</init-param>
public class JaxRsApplication extends javax.ws.rs.core.Application {
    @Override
    public Set<Class<?>> getClasses() {
        final Set<Class<?>> classes = new HashSet<>();
        classes.add(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider.class);
        return classes;
    }
}

JacksonJsonProvider would not be picking up properly as a reader/writer by Jersey 1.x with Jackson 2.8. Same works fine with Jackson 2.7. I don't see any stacktraces. I would try to investigate why integration broke maybe on free time.
For sure I'm for continuing support of first major JaxRS and Jersey versions, migration would be painfull for many projects and they would stuck with 2.7 branch.

@cowtowncoder
Copy link
Member

It is possible to change accessing of NoContentException to use reflection and work with 1.x, but I would like to know what else is triggering problems.

@Spikhalskiy
Copy link
Contributor

Spikhalskiy commented Nov 16, 2016

2.8.5 release works fine for me with Jersey 1.x. NoContentException fix was enough, at least for my usage.

@cowtowncoder
Copy link
Member

@Spikhalskiy excellent, thank you for verifying this.

@cowtowncoder cowtowncoder modified the milestones: 2.8.0, 2.8.5 Nov 16, 2016
@cowtowncoder
Copy link
Member

Fixed via #91

@alexandru-2016
Copy link

alexandru-2016 commented Jan 23, 2017

I am using Jackson 2.8.1 and Jersey 1.18.6, and am getting NoClassDefFoundError: javax/ws/rs/core/NoContentException

I had to include javax.ws.rs-api 2.0.1 to fix this problem, even though I am not using services with JAX-RS 2.0 API

@Spikhalskiy
Copy link
Contributor

@alexandru-2016 it was fixed in 2.8.5 as you can see above.

@sonnyhcl
Copy link

The workaround code is removed in jackson 2.13 with this commit. Is there any other way to workaround with jersey 1.x for legacy users?

@cowtowncoder
Copy link
Member

Version 2.13 did drop JAX-RS 1.x compatibility so Jersey 1.x legacy users should keep using version 2.12; latest patch being 2.12.6.

@dcleao
Copy link

dcleao commented Dec 19, 2023

@alexandru-2016

I am using Jackson 2.8.1 and Jersey 1.18.6, and am getting NoClassDefFoundError: javax/ws/rs/core/NoContentException

I had to include javax.ws.rs-api 2.0.1 to fix this problem, even though I am not using services with JAX-RS 2.0 API

Placing both JAX-RS versions side-by-side will cause a Java loading race-conditions, given the two JAX-RS have same named classes with incompatible definitions. May only reveal itself sometimes, or in some OSs. In my case, the concurrency issue would happen in Windows and resulted in the error:

java.lang.AbstractMethodError: Receiver class com.sun.jersey.api.uri.UriBuilderImpl does not define or inherit an implementation of the resolved method abstract uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder; of abstract class javax.ws.rs.core.UriBuilder.

I think it is better to package the specific missing and needed class, https://github.com/javaee/jax-rs-api/blob/master/jaxrs-api/src/main/java/javax/ws/rs/core/NoContentException.java, in a custom JAR. Worked in my case.

@pjfanning
Copy link
Member

@dcleao do you think having just the NoContentException class in its own jar is enough? If it is that is a nice approach. f58c631 has had a massive impact on Hadoop users and all the Big Data tooling that needs to support Hadoop.

@dcleao
Copy link

dcleao commented Dec 19, 2023

@pjfanning the class itself has no other dependencies.

For FasterXML, I believe I read somewhere that this was a matter of simplifying their code-based, while still somewhat supporting both Jax-RS versions?

I can only state this is working in my case...

@cowtowncoder could you shed some light on if this is a feasible solution, or if hidden problems are likely to arise? Thank you.

@pjfanning
Copy link
Member

I have created https://github.com/pjfanning/jsr311-compat and will try submitting a PR to Hadoop team that uptakes it and a newer version of Jackson.

@cowtowncoder
Copy link
Member

I think @pjfanning 's project sounds like a good solution. FasterXML JAX-RS provider has moved on from Jersey 1.0 and trying to get support back in would be confusing and painful (including but not limited to clashes between JAX-RS 1.0 / 2.0 classes).

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

9 participants