Creating RESTful Web Service with Maven, Jersey 1.8 and JBoss 7.1.1 Final in Eclipse

A few days back my Team Lead asked me to set up a demo web service with Jersey, Jboss 7.1.1 final and Maven in Eclipse Juno. I wasted 2 days flat to search the tutorial & set up only a hello world application in web service. So, I thought . may be this will be of some help who are going to use jersey with jboss in near future.
So, here is the tutorial with screenshots :
(I am assuming that everyone knows how to set up Maven in eclipse or may be you can refer to this tutorial - Installing Maven in Eclipse Juno or Higher

Step: 1
  a. Install Maven for Eclipse.
  b. Open standalone.xml of JBoss Server & comment the sections for jaxrs
      (search with jaxrs & comment them ;))

Step: 2
   Set the repository for Maven in eclipse
   for this, follow the below steps:

   a. Open Preferences in Eclipse (Eclipse Window -> Preferences)
   b. Type Maven in search box & then, click on User Settings.
   c. Set the path for settings.xml for Maven.
Maven Repository Setting : Step 2

   d. Click on Apply.

Step: 3

   Create a new Dynamic Web Project.
   a. File -> New -> Dynamic Web Project.
   b. Give a suitable project name, select Target Runtime as JBoss 7.1 as Runtime & Configuration as Default Configuration for JBoss 7.1 Runtime & click on next.
Creating Dynamic Web Project , Step: 3.b 
c. Click on checkbox: Generate Xml
Step : 3.c
d. Click on Finish.

Step: 4
    Convert the project into Maven Project.

   a. Right click on the project -> configure -> convert to Maven. A box will open prompting to create a pom.xml for the project.
Converting to Maven Project, Step: 4.a

b. Type package name as Group Id & Project Name as Artifact Id & click on Finish. This is very important.

Step: 5

   a. Delete src package from Java Resources.
   b. Create new source folder: src/main/java
Create a source folder, Step : 5.b

   c. The folder structure should now look like this:
Folder Structure

   d. The pom.xml will look like this:
   e. web.xml will look like this:
Step: 6

a. Create a Java class TestRest in
b. Develop the following code like this:

c.  paste this code in web.xml


<display-name>Restful Web 








<param-name></param-name><param-value></param-value></init-param> -->








d. paste this code in pom.xml









<name> Repository for 








































Step: 7

   a. Make sure that the versions of jars is same as the version mentioned in pom.xml.

   b. Make sure that the versions of jerser-server.jar & jersey-core.jar are same.

Step: 8

   Run Maven as Install . Right Click -> Run As -> Maven Install.

Step: 9

   Run on server or export it to a folder & deploy it manually & run the url:

   http://localhost:8080/Test/resources/test/ABC (your port number may be different)

   The output will be : 
Hello ABC

Well, this is the basic Jersey Web Service which is created using Eclipse Juno, Maven, Jersey 1.8 & JBoss 7.1.1 final . In the next post will discuss how to create a client which will use this webservice .

Feel free to share this & post some response. May be, you can just let me know if it is helpful to you.

Related posts:
Using parameters in URLs in Jersey Web Services
Write a Jersey Web Service that returns XML
A Simple Client for Webservice