Wednesday, June 5, 2013

Restful project with Maven Archetype and Jersey

Hi everyone, this is my first post and hope you like it.

Today we will talk about building a Restful project using maven and jersey libraries. For this to be possible maven archetype, a tool to build projects out of templates, will be used.

In this tutorial we will be using command line maven, you can download and follow the installation intructions on

After installation follow the steps below:

1 - Go to your workspace and type:

mvn archetype:generate -DarchetypeCatalog=

2 - Archetypes will be downloaded from the catalog. After downloading you'll see this message "Choose a number or apply a filter", type 3.

3 - After selecting rest archetype, you will fill the project configuration information according to the example below:
groupId - (Identifies your project uniquely between all your projects)
artifactId - blog-restful-webapp (Represents the war name without version)
version - 1.0 (Identifies the project version)
package - (Represent the package structure)

4 - Next, a confirmation message will show up, just type Y and your project will be created.

5 - After the project have been created, type: 

mvn clean install (Clean and build)

6 - The result of previous step should be BUILD SUCCESS, which means that now you already have your rest project fully configured, compiling and ready to be executed.

After doing all these steps you will have import the project into your IDE. In this example eclipse will take place, but be free to use your prefered IDE since maven is IDE agnostic.
Open eclipse and click with the mouse right button on Project Explorer -> Import -> Existing Maven Projects, select your project and click Finish.


Now you can take a look on the class created by the template in

Next, click on the mouse right button over the project and run on your server. In this example we used Tomcat 6.

A page like this should appear.

To access the GET method you just have to access the link:
http://localhost:8080/blog-restful-webapp/webresources/myresource, remember that port should be set accordingly to the server configuration. On this case we used tomcat default port which is 8080.

The template initial configuration establishes that all rest services stays below webresources. This could be easily changed but this is a subject for other post.

Hope you enjoyed it and see you later.



  1. Pra ganhar um 10 com estrelinha, faltou colocar um mvn eclipse:eclipse.

    Parabéns Ivan pela iniciativa.

  2. Ola Ivan parabens pelo post me ajudou muito ! Voce teria algum exemplo utilizando json?

  3. Obrigado pelo feedback Rodrigo. No meu github tem um exemplo de como fazer com JSON. Basicamente vocĂȘ vai ter que mudar o valor dentro de @Produces para application/json.



  4. Greetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.
    Best AWS Training in Chennai | Amazon Web Services Training Institute in Chennai Velachery, Tambaram, OMR
    Advanced AWS Training in Bangalore |Best AWS Training Institute in Bangalore BTMLA ,Marathahalli

  5. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
    microsoft azure training in bangalore
    rpa interview questions and answers
    automation anywhere interview questions and answers
    blueprism interview questions and answers
    uipath interview questions and answers
    rpa training in bangalore

  6. I am a regular reader of your blog and being students it is great to read that your responsibilities have not prevented you from continuing your study and other activities. Love
    python Course in Pune
    python Course institute in Chennai
    python Training institute in Bangalore

  7. Hey, thank you a lot for sharing this article with us. I can’t say how grateful we are to read this. Also, I would love to share it with my friends and family, who are interested. I hope you will publish such articles in the future as well. It’s so helpful. Goodbye!

  8. The 8 best Casino Sites for Slots - Lucky Club
    The 8 best Casino Sites for Slots · 1. 888 Casino – The 8 best casino site for slots · 2. Betway – Best for slots · 3. Playtech – The best casino site · luckyclub 4. Microgaming –