RESTEasy Tutorial Part-1: Basics

 

RESTEasy Tutorial Series

RESTEasy Tutorial Part-1: Basics

RESTEasy Tutorial Part-2: Spring Integration

RESTEasy Tutorial Part 3 – Exception Handling
RESTEasy is a JAX-RS implementation from JBoss/RedHat and is in-built in JBoss 6 onwards.
Here I am going to show you how to develop a Simple RESTful Web Services application using RESTEasy and JBossAS7.1.1.FINAL.

Step#1: Configure RESTEasy dependencies using Maven.

Step#2: Configure RESTEasy in web.xml

Step#3: Create User domain class, MockUserTable class to store User objects in-memory for testing purpose and UserResource class to expose CRUD operations on User as RESTful webservices.

Step#6: JUnit TestCase to test the REST Webservice.

Step#7: To test the REST service we can use the REST Client Tool. 
You can download REST Client Tool at http://code.google.com/a/eclipselabs.org/p/restclient-tool/

Important Things to Keep in mind:
1. org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap Listener should be registered before any other listener.

2. You should configure resteasy.servlet.mapping.prefix <context-param> if the HttpServletDispatcher servlet url-pattern is anything other than /*


3. Keep visiting my blog 🙂

5 thoughts on “RESTEasy Tutorial Part-1: Basics”

  1. Hi Siva,

    thank you for your nice tutorial.
    Could you say something about deploment issues.
    I try to deploy the war file on JBoss 7.1.1 but a ClassNotFoundException is raised for the classes:

    org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher

    and

    org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap

    which are defined in the web.xml file.

    Greetings from Berlin

    Bernd

  2. Hi Bernd,
    Those classes should be part of JBoss-7.1.1 Server.

    org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher class can be found in jboss-as-7.1.1.Finalmodulesorgjbossresteasyresteasy-jaxrsmainasync-http-servlet-3.0-2.3.2.Final.jar.

    org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap class can be found in jboss-as-7.1.1.Finalmodulesorgjbossresteasyresteasy-jaxrsmainresteasy-jaxrs-2.3.2.Final.jar.

  3. Hi, Siva, thank you for this example. What do you think about adding an interface to the UserResource service and moving JAX-RS annotations to the interface? This way you can use this interface in clients to create a service proxy.

Leave a Reply

Your email address will not be published. Required fields are marked *