This example demonstrates how to develop RESTful web service with a Servlet 3.0 and EJB 3.1 container.
The mapping of the URI path space is presented in the following table:
URI path | Resource class | HTTP methods | 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/ | MessageBoardResourceBean | POST | Creates new message and allocates unique id for it (with message as request entity) |
This sample utilizes Java EE features in the GlassFish container
Build the application WAR file by executing maven 2 from the project directory:
mvn 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
You can access the application at: