Java REST implementation: Jersey vs CXF

63,305

Solution 1

I have used both, but for different purposes. CXF worked great to parse a WSDL and create Java POJOs to interact with, so CXF is pretty good for client-side WSDL services. I'm currently using Jersey for server-side implementation and I am impressed with the simplicity of getting up-and-running with RESTful services using Jersey.

As Jersey is mainly devoted to RESTful services and CXF deals mostly (all?) with SOAP, I think it comes down to whether you want to work with SOAP or REST, and determine the best framework for the job from there. Personally, I am more in the REST camp than SOAP, but my needs are different. Should I be in a situation where the vendor/customer/company I write the service for needs some sort of contract, I might still push for REST (and REST's equivalent for contract-based services, WADL), but would likely be required to implement a SOAP service, in which case I would look at CXF first and everything else second.

Personally, Jersey is pretty good for a JAX-RS framework, although don't exclude RESTEasy, by JBoss. I like both, but the documentation for RESTEasy is better.

For CXF, the documentation is OK, but I ran into inconsistencies in how I needed to handle SSL and HTTP Proxies, but it worked itself out eventually. CXF does provide more out of the box regarding these additional features, and I would say RESTEasy would provide the equivalent functionality for RESTful frameworks.

Solution 2

I have only used Jersey (with great satisfaction) so I cannot give a real comparison. Things you might want to consider:

  • CXF is packaged up with SOAP stack support so you bring in a lot of SOAP-related weight you'll never use when you build a RESTful system. (There are plans to split the packaging as far as I know, though)
  • Jersey comes with a number of non-standard additions to JAX-RS that are very helpful. There is also a client side core framework which is designed quite nicely.
  • [Warning: Shameless plug ahead (sorry)]: I have been working on an extended Jersey client side framework that encourages proper use of REST on the client side and is (IMHO at least) very natural to use. It is planned to announce it this (or next) week - if you care about the client side a lot, give it a try. Personally, I'd consider that a huge pro-Jersey argument.

HTH,

Jan

Solution 3

Did you consider RESTlet? It is a powerful package to quickly build RESTful web services. The people behind RESTlet also write the RESTlet In Action book which is currently in early access. The chapters that are already available do a very good job of explaining REST and detailing how you go about designing a REST api.

Solution 4

If you are concerned about the details of converting a solution developed with Jersey to run on CXF, Glen Mazza posted a collection of Jersey samples ported to Apache CXF on GitHub. The README files have notes for each sample regarding necessary changes made.

Solution 5

I've used Apache CXF for JAX-WS and Jersey for JAX-RS so I can't comment about CXF and REST. It was easy to set up a REST example using Jersey. The documentation was adequate. I haven't used RESTEasy but Jersey looks to have more traction and more recent updates.

A good book for implementation guidelines is RESTful Web Services Cookbook.

Share:
63,305
dexter
Author by

dexter

Updated on July 05, 2022

Comments

  • dexter
    dexter almost 2 years

    What do you think is the advantages/disadvantages between this two libraries? Which of these two are best suited for production environment? By the way I will be using JSON instead of XML.

    I also would like to know what library is most supported by the community e.g. tutorials, documentation.

  • iPadDevloperJr
    iPadDevloperJr about 14 years
    Regarding your shameless plug, where might I find some documentation/information/etc. on it that I might be able to give it a whirl?
  • Jan Algermissen
    Jan Algermissen about 14 years
    Nick, I am just typing the introductory blog post. Paul Sandoz is planning to make some final repository changes this morning. Once that is done, we'll go public. You will find the blog at nordsc.com/blog (hopefully this afternoon).
  • Jan Algermissen
    Jan Algermissen about 14 years
    Nick, here you go :-) | Jersey client side framework: nordsc.com/blog/?p=439
  • Dave
    Dave over 12 years
    CXF has separate REST and SOAP Maven artifacts so if you do CXF REST you don't get everything.
  • Dave
    Dave over 12 years
    CXF does REST too. See here: cxf.apache.org/docs/jax-rs.html
  • hotshot309
    hotshot309 over 11 years
    Apache CXF offers three methodologies for using REST: JAX-RS, JAX-WS, and HTTP binding.
  • Ankur Loriya
    Ankur Loriya almost 8 years
    link is broken can you update it, if it is possible
  • David J. Liszewski
    David J. Liszewski almost 8 years
    @AnkurLoriya I tried. Glen moved his blog to web-gmazza.rhcloud.com, but I couldn't find that article there. I'll fix answer.