JBoss.orgCommunity Documentation

Chapter 3. RestEasy simple project example

3.1. The example project

JBoss Tools includes many example projects which are available by selecting HelpProject Examples. The following sections describe setting up the example RESTEasy project. This project serves as a good example for testing the numerous Web Service Test View functions.

Once the required plugins have been installed, the example project can be set up as described in JBoss Tools New Example Project

Procedure 3.1. JBoss Tools New Example Project

  1. Access the New Example Project Dialog

    Select HelpProject Examples

    Result:

    The New Example Project dialog displays.

  2. Define the Example Project Type

    1. Click the RESTEasy Simple Example label by expanding the RESTEasy node.

    2. Click the Finish button to complete the project set up.

    Result:

    The simple project is configured and ready to build.

    Project requirements

    In the event that a message is displayed indicating some requirements could not be configured, click the Details button followed by the Fix button to rectify the problem. The message will be displayed as a result of missing plugins or a requirement to select or configure a suitable runtime.

  3. Build the project

    Right click on the project name and select Run AsMaven package

    Result:

    The simple.war file is written to the project's 'target directory.

  4. Deploy the project

    Copy the simple.war file to the deploy directory of the required server profile such as the all profile.

    Result:

    The simple.war file is written to the target directory.

  5. Determine the URL for the web service

    Double click the web.xml file and note the jax.ws.rs.Application parameter mapped to the Application class. Note also that:

    • the main servlet for the application is org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher which is given the custom name Resteasy; and

    • the main servlet is mapped to the url /rest-services/* [1].

    The url for sending GET requests can be resolved as follows:

    1. Identify the Application class as defined in the deployment descriptor.

    2. Note the object type (CustomerResource) instantiated in the Application class (ShoppingApplication) and added to the singleton set (singletons.add(new CustomerResource())).

    3. Note the JAX-RS annotated path declared in the corresponding CustomerResource class: @Path("/customers") [2].

    Figure 3.1. web.xml


    The url for sending GET requests can be formed from http://localhost:8080/ProjectName/[1]/[2] or, http://localhost:8080/simple/rest-services/customers..