Accessing an EJB from a web service (JAX-RS)

Java EE 6 supports Java API for RESTful Web Services (JAX-RS), a Representational State Transfer (RESTful) web service. This type of service does not require WDSL or XML messages. In this recipe we will create a simple RESTful application, RESTApplication, which returns a random tip of the day message.

The beauty of this application is its simplicity and ease of development. We will create two EJBs: one for the application's functionality and a second one to represent the Web Service.

Getting ready

To create a JAX-RS application we need to:

  1. Create an EJB to support the functionality of the web service
  2. Create a web service EJB annotated with the @Path annotation

    The use of annotations makes both of these ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.