Jersey EJB Example

This example demonstrates how to develop RESTful web service with a Servlet 3.0 and EJB 3.1 container.

Contents

The mapping of the URI path space is presented in the following table:

URI path Resource class HTTP method Description
/jersey-ejb --- GET Simple html/ajax client
/jersey-ejb/app/messages MessageBoardResourceBean GET Returns first ten messsages
/jersey-ejb/app/messages/{id} MessageBoardResourceBean GET Returns message with uniqueId = {id} or returns HTTP 404 if message does not exist
/jersey-ejb/app/messages/{id} MessageBoardResourceBean DELETE Deletes message with uniqueId = {id} or returns HTTP 404 if message does not exist
/jersey-ejb/app/messages/
(with message as request entity)
MessageBoardResourceBean POST Creates new message and allocates unique id for it

Running the Example

This sample utilizes Java EE features in the GlassFish container

Build the application WAR file by executing maven 2 from the project directory:

mvn -Dmaven.test.skip clean package

To deploy on a running GlassFish container, you would then typically need to launch:

$AS_HOME/bin/asadmin deploy target/jersey-ejb.war

Another option is to deploy using GlassFish administrator console GUI

From a web browser, visit:

http://localhost:8080/jersey-ejb