Using RESTEasy with Codenvy

Instantly create a RestEasy project off a Codenvy Factory:

RESTEasy is a JBoss project that provides various frameworks to help you build RESTful Web Services and RESTful Java applications. It is a fully certified and portable implementation of the JAX-RS specification. JAX-RS is a new JCP specification that provides a Java API for RESTful Web Services over the HTTP protocol.

Create a Project

Login to your codenvy workspace and create a New WAR Project say “RESTEasy”. Project file structure is shown below :

GetImage (13)

Add Dependencies

Specify the below dependencies in pom.xml which are prerequisites. Make sure these jars are included under Maven Dependencies.

GetImage (14)

Pom.xml :


Create HelloWorldService Class

In this example, web request from “projectURL/rest/hello/” will match to “HelloWorldService“, via @Path(“/hello”).

And the “{any values}” from “projectURL/rest/hello/{any values}” will match to parameter annotated with @PathParam.

Code Logic :

package com.codenvy;

public class HelloWorldService {

public Response printMessage(@PathParam("param") String msg) {
String result = "RESTEasy says : Hello " + msg;
return Response.status(200).entity(result).build();

Create index.jsp:

Sample index page for the web application giving a sample link (url) to HelloWorldservice created.

<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="460" bgcolor="#EEFFCA">
<tr><td width="100%"><font size="6" color="#008000"><a href="/rest/hello/codenvy">HelloWorldService</a></font></td></tr>

Create web.xml:

"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"" >
<display-name>Restful Web Application</display-name>
<!-- Auto scan REST service -->
<!-- this need same with resteasy servlet url-pattern -->

Build and Run the application

Upon successful building the application and navigating to url “projectURL/rest/hello/codenvy”, it displays.

GetImage (15)