35

I'm starting a new Java project which will require a RESTful API. It will be a SaaS business application serving mobile clients.

I have developed one project with Java EE 6, but I'm not very familiar with the ecosystem, since most of my experience is on the Microsoft platform.

Which would be a sensible choice for a JAX-RS implementation for a new project such as described?

Judging by Wikipedia's list, main contenders seem to be Jersey, Apache CXF, RESTeasy and Restlet. But the Comparison of JAX-RS Implementations cited on Wikipedia is from 2008.

My first impressings from their respective homepages is that:

  • CXF aims to be a very comprehensive solution (reminds me of WCF in the Microsoft space), which makes me think it can be more complex to understand, setup and debug than what I need;
  • Jersey is the reference implementation and might be a good choice, but it's legacy from Sun and I'm not sure how Oracle is treating it (announcements page doesn't work and last commit notice is from 4 months ago);
  • RESTeasy is from JBoss and probably a solid option, though I'm not sure about learning curve;
  • Restlet seems to be popular but has a lot of history, I'm not sure how up-to-date it is in the Java EE 6 world or if it carries a heavy J2EE mindset (like lots of XML configuration).

What would be the merits of each of these alternatives? What about learning curve? Feature support? Tooling (e.g. NetBeans or Eclipse wizards)? What about ease of debugging and also deployment? Is any of these project more up-to-date than the others? How stable are them?

Oleksi
  • 11,874
  • 2
  • 53
  • 54
Fernando Correia
  • 465
  • 1
  • 4
  • 8
  • 1
    I appreciate the title edit, but I'm not really asking whether JAX-RS is a good fit for a mobile project; that would be another question. I'm trying to find out which JAX-RS implementation would be recommended. – Fernando Correia Jul 03 '12 at 18:36

2 Answers2

22

I've grown to love Dropwizard for an overall solution

Rather than go with some huge application container approach, Dropwizard advocates a lightweight solution that offers much faster development cycles. Essentially, it provides the glue for the following well-known frameworks:

  • Jetty (HTTP)
  • Jersey (JAX-RS)
  • Jackson (JSON or XML)
  • Guava (excellent additions to JDK libraries)
  • Metrics (real time application monitoring)
  • Hibernate Validator (input verification)
  • OAuth (RESTful authentication)

The combination of the above, coupled with a solid approach to functional testing, gives a complete solution to getting your service up and running quickly.

Yeah? And the JAX-RS question I asked...

You'll notice that their choice was Jersey, the reference JAX-RS implementation. Being a RESTEasy guy I thought this would be a problem, but there was zero learning curve. The two are largely interchangeable. However, I would say that the Jersey client offered a fluent interface for constructing tests. An example would be...

 @Override
  protected void setUpResources() {
    addResource(new HelloWorldResource("Hello, %s!","Stranger"));

    setUpAuthenticator();
  }

  @Test
  public void simpleResourceTest() throws Exception {

    Saying expectedSaying = new Saying(1,"Hello, Stranger!");

    Saying actualSaying = client()
      .resource("/hello-world")
      .get(Saying.class);

    assertEquals("GET hello-world returns a default",expectedSaying.getContent(),actualSaying.getContent());

}
Lambart
  • 103
  • 2
Gary
  • 24,420
  • 9
  • 63
  • 108
  • 2
    Thank you so much for bringing Dropwizard to my attention. I didn't know about it and it seems to fit my needs very well. It looks well thought out, practical and down-to-earth and could probably save me a lot of trouble while helping me build a much better solution than I could given my superficial knowledge of the Java EE platform. And coming from a successful company like Yammer that serves the corporate market is definitely a plus. Again, many thanks. – Fernando Correia Jul 04 '12 at 16:26
  • 1
    No problem. I've blogged about a project of mine that demonstrates many of the Dropwizard features. It's under MIT license so feel free to use as you need: http://gary-rowe.com/agilestack/2012/06/06/multibit-merchant-deployment-driven-design/ – Gary Jul 04 '12 at 19:22
  • That'll help. Much appreciated. – Fernando Correia Jul 04 '12 at 20:03
  • 1
    I was already leaning toward using Jackson, Guava, Validator and OAuth, so this looks like a no-brainer... Thanks. – PhiLho Jan 17 '13 at 09:51
  • Warning: Jersey 2.0 is substantially worse than 1.0. It is missing functionality that used to exist in 1.0, it forces a specific DI framework on you, and the community support is much much worse than it used to be. – Gili Dec 06 '13 at 04:38
  • Recent benchmarking of a functionally equivalent micro-service written in both dropwizard and ring ( see http://glennengstrand.info/software/performance/clojure/dropwizard ) definitely shows dropwizard to have very good performance and reasonably good scalability. – Glenn Dec 06 '16 at 06:14
6

You can take a look at this question, which discusses some experiences from other developers.

I can personally recommend Jersey. It's very easy to use, and it has a good following because it's the reference implementation. This also means that it'll be maintained and supported for the next little while.

Oleksi
  • 11,874
  • 2
  • 53
  • 54
  • 1
    Thank you for your helpful answer and for linking to that related question -- strangely, it didn't show up in the [search](http://programmers.stackexchange.com/search?q=%5Bjava%5D+%5Brest%5D+frameworks). That answer is from 4 years ago, though, so I appreciate your up-to-date recommendation. – Fernando Correia Jul 03 '12 at 18:33