Rest webservice using: Jersey, Guice, JPA 2.0 (EclipseLink), SQlite, Jetty.

Project description

I have created a simple tutorial project which binds some of java technologies that can be use while writing webservices.
Project is available on github at

Important informations

Technologies/Frameworkds that are used:

  1. Maven (building, organizing tool)
  2. Jersey (JAX-RS implementation)
  3. Guice (IoC Container)
  4. EclipseLink (JPA 2.0 implementation – ORM)
  5. SQlite (Database)
  6. Jetty (Application Server)

How to use

To run the server you need to execute program. Class com.morcinek.server.webservice.Main contains main() method. So you can easily execute it in debug or normal mode through your IDE. If you are old-school you can always compile it with maven and run it in command line.
First time you run it, program creates database. In our case, since we use SQLite, there will be file sample.db created.

How to access webservice resources


As it is set in main() method. You can access resources from localhost where port number is 8080 and context path /api.

    public static final String CONTEXT_PATH = "/api";
    public static final int PORT = 8080;
        Server server = new Server(PORT);
        ServletContextHandler root = new ServletContextHandler(server, CONTEXT_PATH, ServletContextHandler.SESSIONS);

Base URL

Base url looks like this: http://localhost:8080/api/.


The Application Resource have path /service, with two specific path

  1. /authors returns list of authors in json.
  2. /date returns current system date.

and :

    public Response getAuthors() {
    public Response getSystemDate() {


You can access those resources under:

  1. http://localhost:8080/api/service/authors
  2. http://localhost:8080/api/service/date

Where to find it

As it was mentioned above, the tutorial project you can find on github at


If you want some more information about how to create rest webservices please visit my other posts, where I describe (step by step), how to create one:
First restful web service with mave
Restful web service with maven – continuation



Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:


Komentujesz korzystając z konta Wyloguj /  Zmień )

Zdjęcie na Google+

Komentujesz korzystając z konta Google+. Wyloguj /  Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Wyloguj /  Zmień )

Zdjęcie na Facebooku

Komentujesz korzystając z konta Facebook. Wyloguj /  Zmień )


Connecting to %s