Difference between JAX-RS, Restlet, Jersey, RESTEasy, and Apache CXF Frameworks

The JAX-RS is a Java specification request (JSR 311 & JSR 339) which standardize development and deployment of RESTful web services using Java and JEE technologies. It provides API in Java Programming language to create web services according to the REST (Representational State Transfer) architectural pattern. Both Restlet and Jersey are two of the most popular implementation of JAX-RS used for developing RESTful web services in Java ecosystem but there are a couple of other implementation also exist e.g. Apache Wink, Apache CXF, and JBoss RESTEasy. In this article, I'll introduce with these RESTful web services framework in Java world. It's not a very detailed post about strength and weakness of each of the framework but will just give you enough to understand them in detail later.

It will also help you to answer the RESTful web service questions like, what is the difference between Restlet, Jersey, and Apache CFX? which one you have used in past, or which one will you choose for your next project and why?

Jersey RESTful Web Services framework is open source, production quality, a framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) reference Implementation and initially provided by Sun Microsystem.

Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides its own API that extends the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development. Jersey also exposes numerous extension SPIs so that developers may extend Jersey to best suit their needs.

Jersey also has some of the best tooling (IDE) support especially if you are using Netbeans. So you can achieve better productivity from the tooling perspective. There are some challenges with Jersey-Spring integration, especially with AOP.

The latest release of Jersey is 2.22.2

One of the first open source framework for developing RESTful web services in Java. Restlet Framework helps Java developers build better web APIs that follow the REST architecture style. Restlet has a light core but thanks to its pluggable extension, it is also a comprehensive REST framework for Java. It supports all REST concepts (Resource, Representation, Connector, Component, etc.) and is suitable for both client and server Web applications.

It supports major Web standards like HTTP, SMTP, XML, JSON, OData, OAuth, RDF, RSS, WADL, and Atom.

Many extensions are also available to integrate with Servlet, Spring, Jetty, Simple, JAXB, JAX-RS, JiBX, Velocity, FreeMarker, XStream, Jackson, SLF4J, SDC and much more!

Special editions for Android, GWT, GAE, Java SE, Java EE, and OSGi are also available and kept synchronized with an automated porting process.

Another advantage of using Restlet framework is that Restlet based program can run as a standalone Java application. The Restlet also supports Java EE environment with the help of Jetty web container. So this may result in a light-weight implementation and have a unique value that way. There are some challenges or manual work involved in de-marshalling the response into java object. See Restlet in Action to learn more about the Restlet framework.

Difference between JAX-RS, Restlet, Jersey, RESTEasy, and Apache CXF Frameworks

The CXF is another free and open source web service framework and a JAX-RS implementation from Apache. CXF helps you to build and develop services using frontend programming APIs like JAX-RS and JAX-WS. These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS, and JBI.

One of the key difference between Apache CXF and Jersy's JAX-RS implementation is that it is implemented as a CXF filter sitting behind the servlets, while Jersey and RestEasy are, servlet filters.

One more advantage of using ApacheCXF is that it makes it easy to produce both a JAX-RS and JAX-WS (SOAP) endpoint from the exact same data model and service interface at the same time. So if that is something which matters to you, this may be the way to go. CXF had issues with handling SSL and HTTP proxies which seem to have been addressed in recent releases.  You can also read Developing Web Services with Apache CXF and Axis2 to learn more about developing RESTful web services using Apache CXF framework in Java.

Difference between JAX-RS, Restlet, Jersey, and Apache CXF Framework

The RESTEasy is another good JBoss project that provides various frameworks to help you build RESTful Web Services and RESTful Java applications. It is a fully certified and portable implementation of the JAX-RS specification.

RESTEasy may be a good choice if your environment is JBoss oriented e.g. you are using JBoss Application Server, Hibernate and RedHat Middleware, Linux etc. It also provides good integration with EJB 3.0 and SEAM (something to consider if you have a need for that). Also, it has a proprietary caching for URL or query which could be handy for high volume applications.

Difference between Restlet, Jersey, RESTEasy, and Apache CXF Frameworks

That's all about the difference between JAX-RS, Restlet, and Jersey in Java. In short, JAX-RS provides the API and these two are the implementation of that API, where Jersey serves as reference implementation but Restlet has got bigger and more matured community around it. All of these are also mature and production ready frameworks. Chances of going wrong with any of them are quite less. They all have integration capabilities with Spring.  So You can use either Restlet, Jersey or any other framework to develop RESTful web services in Java.

If you have some Java experience but new to REST and want to learn how to develop RESTful web services in Java, then you can also check out Eugen's REST with Spring course, which will teach you developing RESTful Web Services using Spring Framework. The course is very detailed and expects that you are familiar with Spring framework, so ideal for intermediate and experienced Java programmers.

Eugen also has different options suited to different experience level and needs e.g. REST with Spring: The Intermediate class is good for basic knowledge while REST with Spring: The Masterclass is more detail oriented. You can check out all his course options here.

Other REST tutorials and articles you may like to explore
  1. Restlet HelloWorld Example in Java and Eclipse (tutorial
  2. What is the difference between SOAP and REST Web Services? (see here
  3. 15 REST Web Services framework Interview Question (see here
  4. What are idempotent and safe methods of HTTP and REST? (answer
  5. Top 10 RESTful web services interview questions for Java developers (see
  6. What is the purpose of different HTTP methods in REST? (answer
  7. Top 10 Java Web service interview questions (see here
  8. When to use PUT vs POST method in REST? (answer
  9. 3 ways to convert String to JSON Object in Java? (example
  10. 5 JSON parsing library Java and JEE developer should know (article)

Further Reading
RESTful Web Services by Leonard Richardson

Thanks for reading this article, if you like this article then please share with your friends and colleagues. If you have any suggestion or feedback then please drop a note. 

No comments :

Post a Comment