» Using a Java EE RESTEasy resource
These tutorials are no longer maintained. Some of these tutorials continue to be maintained for the lecture Advanced Concepts in Software Engineering.

Example project

This tutorial will show how to import a Java EE RESTEasy application using the example of a simple adder application. It allows you to quickly get started with Eclipse and RESTEasy.

  1. Download the adder service application source files (Project on GitHub) to a temporary folder.
  2. Import the archive as described in the basic Java EE tutorial.

    RESTEasy project in Eclipse Imported Project AdderServiceResteasy

  3. Once you published your projects onto your application server and started the server, your adder service is accessible under http://localhost:8080/AdderServiceResteasy/api/.
  4. Try changing parts of the URI, i.e. …/api/add/1/3/. Also try to send different Accept-Header using a curl-like tool such as httpie, REST Console for Chrome, or RESTClient for Firefox to see how the resource responds with different representations.
  5. Also try the sample client that uses the RESTEasy web service.

Enabling RESTEasy

Using a dynamic web project, add the following to your WEB-INF/web.xml in order to let RESTEasy discover your resources:

<servlet-mapping>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>