Chapter 1. Getting Started
Prev |  | Next

Links: Table of Contents | Single HTML

# Chapter 1. Getting Started

This chapter provides a quick introduction on how to get started building RESTful services using Jersey. The example described here uses the lightweight Grizzly HTTP server. At the end of this chapter you will see how to implement equivalent functionality as a JavaEE web application you can deploy on any servlet container supporting Servlet 2.5 and higher.

## 1.1. Creating a New Project from Maven Archetype

Jersey project is built using Apache Maven software project build and management tool. All modules produced as part of Jersey project build are pushed to the Central Maven Repository. Therefore it is very convenient to work with Jersey for any Maven-based project as all the released (non-SNAPSHOT) Jersey dependencies are readily available without a need to configure a special maven repository to consume the Jersey modules.

### Note

In case you want to depend on the latest SNAPSHOT versions of Jersey modules, the following repository configuration needs to be added to your Maven project pom:

    <repository>
        <id>snapshot-repository.java.net</id>
        <name>Java.net Snapshot Repository for Maven</name>
        <url>https://maven.java.net/content/repositories/snapshots/</url>
        <layout>default</layout>
    </repository>

Since starting from a Maven project is the most convenient way for working with Jersey, let's now have a look at this approach. We will now create a new Jersey project that runs on top of a Grizzly container. We will use a Jersey-provided maven archetype. To create the project, execute the following Maven command in the directory where the new project should reside:

    mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 \
    -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \
    -DgroupId=com.example -DartifactId=simple-service -Dpackage=com.example \
    -DarchetypeVersion=2.26-b06

Feel free to adjust the `groupId`, `package` and/or `artifactId` of your new project. Alternatively, you can change it by updating the new project pom.xml once it gets generated.

## 1.2. Exploring the Newly Created Project

Once the project generation from a Jersey maven archetype is successfully finished, you should see the new `simple-service` project directory created in your current location. The directory contains a standard Maven project structure:

Project build and management configuration is described in the `pom.xml` located in the project root directory.
Project sources are located under `src/main/java`.
Project test sources are located under `src/test/java`.

There are 2 classes in the project source directory in the `com.example` package. The `Main` class is responsible for bootstrapping the Grizzly container as well as configuring and deploying the project's JAX-RS application to the container. Another class in the same package is `MyResource` class, that contains implementation of a simple JAX-RS resource. It looks like this:

    package com.example;

    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.core.MediaType;

    /**
     * Root resource (exposed at "myresource" path)
     */
    @Path("myresource")
    public class MyResource {

        /**
         * Method handling HTTP GET requests. The returned object will be sent
         * to the client as "text/plain" media type.
         *
         * @return String that will be returned as a text/plain response.
         */
        @GET
        @Produces(MediaType.TEXT_PLAIN)
        public String getIt() {
            return "Got it!";
        }
    }

A JAX-RS resource is an annotated POJO that provides so-called resource methods that are able to handle HTTP requests for URI paths that the resource is bound to. See Chapter 3, JAX-RS Application, Resources and Sub-Resources for a complete guide to JAX-RS resources. In our case, the resource exposes a single resource method that is able to handle HTTP `GET` requests, is bound to `/myresource` URI path and can produce responses with response message content represented in `"text/plain"` media type. In this version, the resource returns the same `"Got it!"` response to all client requests.

The last piece of code that has been generated in this skeleton project is a `MyResourceTest` unit test class that is located in the same `com.example` package as the `MyResource` class, however, this unit test class is placed into the maven project test source directory `src/test/java` (certain code comments and JUnit imports have been excluded for brevity):

    package com.example;

    import javax.ws.rs.client.Client;
    import javax.ws.rs.client.ClientBuilder;
    import javax.ws.rs.client.WebTarget;

    import org.glassfish.grizzly.http.server.HttpServer;

    ...

    public class MyResourceTest {

        private HttpServer server;
        private WebTarget target;

        @Before
        public void setUp() throws Exception {
            server = Main.startServer();

            Client c = ClientBuilder.newClient();
            target = c.target(Main.BASE_URI);
        }

        @After
        public void tearDown() throws Exception {
            server.stop();
        }

        /**
         * Test to see that the message "Got it!" is sent in the response.
         */
        @Test
        public void testGetIt() {
            String responseMsg = target.path("myresource").request().get(String.class);
            assertEquals("Got it!", responseMsg);
        }
    }

In this unit test, a Grizzly container is first started and server application is deployed in the test `setUp()` method by a static call to `Main.startServer()`. Next, a JAX-RS client components are created in the same test set-up method. First a new JAX-RS client instance `c` is built and then a JAX-RS web target component pointing to the context root of our application deployed at `http://localhost:8080/myapp/` (a value of `Main.BASE_URI` constant) is stored into a `target` field of the unit test class. This field is then used in the actual unit test method (`testGetIt()`).

In the `testGetIt()` method a fluent JAX-RS Client API is used to connect to and send a HTTP `GET` request to the `MyResource` JAX-RS resource class listening on `/myresource` URI. As part of the same fluent JAX-RS API method invocation chain, a response is read as a Java `String` type. On the second line in the test method, the response content string returned from the server is compared with the expected phrase in the test assertion. To learn more about using JAX-RS Client API, please see the Chapter 5, Client API chapter.

## 1.3. Running the Project

Now that we have seen the content of the project, let's try to test-run it. To do this, we need to invoke following command on the command line:

    mvn clean test

This will compile the project and run the project unit tests. We should see a similar output that informs about a successful build once the build is finished:

    Results :

    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 34.527s
    [INFO] Finished at: Sun May 26 19:26:24 CEST 2013
    [INFO] Final Memory: 17M/490M
    [INFO] ------------------------------------------------------------------------

Now that we have verified that the project compiles and that the unit test passes, we can execute the application in a standalone mode. To do this, run the following maven command:

    mvn exec:java

The application starts and you should soon see the following notification in your console:

    May 26, 2013 8:08:45 PM org.glassfish.grizzly.http.server.NetworkListener start
    INFO: Started listener bound to [localhost:8080]
    May 26, 2013 8:08:45 PM org.glassfish.grizzly.http.server.HttpServer start
    INFO: [HttpServer] Started.
    Jersey app started with WADL available at http://localhost:8080/myapp/application.wadl
    Hit enter to stop it...

This informs you that the application has been started and it's WADL descriptor is available at `http://localhost:8080/myapp/application.wadl` URL. You can retrieve the WADL content by executing a `curl http://localhost:8080/myapp/application.wadl` command in your console or by typing the WADL URL into your favorite browser. You should get back an XML document in describing your deployed RESTful application in a WADL format. To learn more about working with WADL, check the Chapter 17, WADL Support chapter.

The last thing we should try before concluding this section is to see if we can communicate with our resource deployed at `/myresource` path. We can again either type the resource URL in the browser or we can use `curl`:

    $ curl http://localhost:8080/myapp/myresource
    Got it!

As we can see, the `curl` command returned with the `Got it!` message that was sent by our resource. We can also ask `curl` to provide more information about the response, for example we can let it display all response headers by using the `-i` switch:

    curl -i http://localhost:8080/myapp/myresource
    HTTP/1.1 200 OK
    Content-Type: text/plain
    Date: Sun, 26 May 2013 18:27:19 GMT
    Content-Length: 7

    Got it!

Here we see the whole content of the response message that our Jersey/JAX-RS application returned, including all the HTTP headers. Notice the `Content-Type: text/plain` header that was derived from the value of @Produces annotation attached to the `MyResource` class.

In case you want to see even more details about the communication between our `curl` client and our resource running on Jersey in a Grizzly I/O container, feel free to try other various options and switches that `curl` provides. For example, this last command will make `curl` output a lot of additional information about the whole communication:

    $ curl -v http://localhost:8080/myapp/myresource
    * About to connect() to localhost port 8080 (#0)
    *   Trying ::1...
    * Connection refused
    *   Trying 127.0.0.1...
    * connected
    * Connected to localhost (127.0.0.1) port 8080 (#0)
    > GET /myapp/myresource HTTP/1.1
    > User-Agent: curl/7.25.0 (x86_64-apple-darwin11.3.0) libcurl/7.25.0 OpenSSL/1.0.1e zlib/1.2.7 libidn/1.22
    > Host: localhost:8080
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < Content-Type: text/plain
    < Date: Sun, 26 May 2013 18:29:18 GMT
    < Content-Length: 7
    <
    * Connection #0 to host localhost left intact
    Got it!* Closing connection #0

## 1.4. Creating a JavaEE Web Application

To create a Web Application that can be packaged as WAR and deployed in a Servlet container follow a similar process to the one described in Section 1.1, “Creating a New Project from Maven Archetype”. In addition to the Grizzly-based archetype, Jersey provides also a Maven archetype for creating web application skeletons. To create the new web application skeleton project, execute the following Maven command in the directory where the new project should reside:

    mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp \
                    -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \
                    -DgroupId=com.example -DartifactId=simple-service-webapp -Dpackage=com.example \
                    -DarchetypeVersion=2.26-b06

As with the Grizzly based project, feel free to adjust the `groupId`, `package` and/or `artifactId` of your new web application project. Alternatively, you can change it by updating the new project `pom.xml` once it gets generated.

Once the project generation from a Jersey maven archetype is successfully finished, you should see the new `simple-service-webapp` project directory created in your current location. The directory contains a standard Maven project structure, similar to the `simple-service` project content we have seen earlier, except it is extended with an additional web application specific content:

Project build and management configuration is described in the `pom.xml` located in the project root directory.
Project sources are located under `src/main/java`.
Project resources are located under `src/main/resources`.
Project web application files are located under `src/main/webapp`.

The project contains the same `MyResouce` JAX-RS resource class. It does not contain any unit tests as well as it does not contain a `Main` class that was used to setup Grizzly container in the previous project. Instead, it contains the standard Java EE web application `web.xml` deployment descriptor under `src/main/webapp/WEB-INF`. The last component in the project is an `index.jsp` page that serves as a client for the `MyResource` resource class that is packaged and deployed with the application.

To compile and package the application into a WAR, invoke the following maven command in your console:

    mvn clean package

A successful build output will produce an output similar to the one below:

    Results :

    Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

    [INFO]
    [INFO] --- maven-war-plugin:2.1.1:war (default-war) @ simple-service-webapp ---
    [INFO] Packaging webapp
    [INFO] Assembling webapp [simple-service-webapp] in [.../simple-service-webapp/target/simple-service-webapp]
    [INFO] Processing war project
    [INFO] Copying webapp resources [.../simple-service-webapp/src/main/webapp]
    [INFO] Webapp assembled in [75 msecs]
    [INFO] Building war: .../simple-service-webapp/target/simple-service-webapp.war
    [INFO] WEB-INF/web.xml already added, skipping
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 9.067s
    [INFO] Finished at: Sun May 26 21:07:44 CEST 2013
    [INFO] Final Memory: 17M/490M
    [INFO] ------------------------------------------------------------------------

Now you are ready to take the packaged WAR (located under `./target/simple-service-webapp.war`) and deploy it to a Servlet container of your choice.

### Important

To deploy a Jersey application, you will need a Servlet container that supports Servlet 2.5 or later. For full set of advanced features (such as JAX-RS 2.0 Async Support) you will need a Servlet 3.0 or later compliant container.

## 1.5. Creating a Web Application that can be deployed on Heroku

To create a Web Application that can be either packaged as WAR and deployed in a Servlet container or that can be pushed and deployed on Heroku the process is very similar to the one described in Section 1.4, “Creating a JavaEE Web Application”. To create the new web application skeleton project, execute the following Maven command in the directory where the new project should reside:

    mvn archetype:generate -DarchetypeArtifactId=jersey-heroku-webapp \
                    -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \
                    -DgroupId=com.example -DartifactId=simple-heroku-webapp -Dpackage=com.example \
                    -DarchetypeVersion=2.26-b06

Adjust the `groupId`, `package` and/or `artifactId` of your new web application project to your needs or, alternatively, you can change it by updating the new project `pom.xml` once it gets generated.

Once the project generation from a Jersey maven archetype is successfully finished, you should see the new `simple-heroku-webapp` project directory created in your current location. The directory contains a standard Maven project structure:

Project build and management configuration is described in the `pom.xml` located in the project root directory.
Project sources are located under `src/main/java`.
Project resources are located under `src/main/resources`.
Project web application files are located under `src/main/webapp`.
Project test-sources (based on JerseyTest) are located under `src/test/java`.
Heroku system properties (OpenJDK version) are defined in `system.properties`.
Lists of the process types in an application for Heroku is in `Procfile`.

The project contains one JAX-RS resource class, `MyResouce`, and one resource method which returns simple text message. To make sure the resource is properly tested there is also a end-to-end test-case in `MyResourceTest` (the test is based on JerseyTest from our Chapter 26, Jersey Test Framework). Similarly to `simple-service-webapp`, the project contains the standard Java EE web application `web.xml` deployment descriptor under `src/main/webapp/WEB-INF` since the goal is to deploy the application in a Servlet container (the application will run in Jetty on Heroku).

To compile and package the application into a WAR, invoke the following maven command in your console:

    mvn clean package

A successful build output will produce an output similar to the one below:

        Results :

        Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

        [INFO]
        [INFO] --- maven-war-plugin:2.2:war (default-war) @ simple-heroku-webapp ---
        [INFO] Packaging webapp
        [INFO] Assembling webapp [simple-heroku-webapp] in [.../simple-heroku-webapp/target/simple-heroku-webapp]
        [INFO] Processing war project
        [INFO] Copying webapp resources [.../simple-heroku-webapp/src/main/webapp]
        [INFO] Webapp assembled in [57 msecs]
        [INFO] Building war: .../simple-heroku-webapp/target/simple-heroku-webapp.war
        [INFO] WEB-INF/web.xml already added, skipping
        [INFO]
        [INFO] --- maven-dependency-plugin:2.8:copy-dependencies (copy-dependencies) @ simple-heroku-webapp ---
        [INFO] Copying hk2-locator-2.2.0-b21.jar to .../simple-heroku-webapp/target/dependency/hk2-locator-2.2.0-b21.jar
        [INFO] Copying jetty-security-9.0.6.v20130930.jar to .../simple-heroku-webapp/target/dependency/jetty-security-9.0.6.v20130930.jar
        [INFO] Copying asm-all-repackaged-2.2.0-b21.jar to .../simple-heroku-webapp/target/dependency/asm-all-repackaged-2.2.0-b21.jar
        [INFO] Copying jersey-common-2.5.jar to .../simple-heroku-webapp/target/dependency/jersey-common-2.5.jar
        [INFO] Copying validation-api-1.1.0.Final.jar to .../simple-heroku-webapp/target/dependency/validation-api-1.1.0.Final.jar
        [INFO] Copying jetty-webapp-9.0.6.v20130930.jar to .../simple-heroku-webapp/target/dependency/jetty-webapp-9.0.6.v20130930.jar
        [INFO] Copying jersey-container-servlet-2.5.jar to .../simple-heroku-webapp/target/dependency/jersey-container-servlet-2.5.jar
        [INFO] Copying cglib-2.2.0-b21.jar to .../simple-heroku-webapp/target/dependency/cglib-2.2.0-b21.jar
        [INFO] Copying osgi-resource-locator-1.0.1.jar to .../simple-heroku-webapp/target/dependency/osgi-resource-locator-1.0.1.jar
        [INFO] Copying hk2-utils-2.2.0-b21.jar to .../simple-heroku-webapp/target/dependency/hk2-utils-2.2.0-b21.jar
        [INFO] Copying hk2-api-2.2.0-b21.jar to .../simple-heroku-webapp/target/dependency/hk2-api-2.2.0-b21.jar
        [INFO] Copying jetty-io-9.0.6.v20130930.jar to .../simple-heroku-webapp/target/dependency/jetty-io-9.0.6.v20130930.jar
        [INFO] Copying jetty-server-9.0.6.v20130930.jar to .../simple-heroku-webapp/target/dependency/jetty-server-9.0.6.v20130930.jar
        [INFO] Copying jetty-util-9.0.6.v20130930.jar to .../simple-heroku-webapp/target/dependency/jetty-util-9.0.6.v20130930.jar
        [INFO] Copying jersey-client-2.5.jar to .../simple-heroku-webapp/target/dependency/jersey-client-2.5.jar
        [INFO] Copying jetty-http-9.0.6.v20130930.jar to .../simple-heroku-webapp/target/dependency/jetty-http-9.0.6.v20130930.jar
        [INFO] Copying guava-14.0.1.jar to .../simple-heroku-webapp/target/dependency/guava-14.0.1.jar
        [INFO] Copying jetty-xml-9.0.6.v20130930.jar to .../simple-heroku-webapp/target/dependency/jetty-xml-9.0.6.v20130930.jar
        [INFO] Copying jersey-server-2.5.jar to .../simple-heroku-webapp/target/dependency/jersey-server-2.5.jar
        [INFO] Copying jersey-container-servlet-core-2.5.jar to .../simple-heroku-webapp/target/dependency/jersey-container-servlet-core-2.5.jar
        [INFO] Copying javax.ws.rs-api-2.0.jar to .../simple-heroku-webapp/target/dependency/javax.ws.rs-api-2.0.jar
        [INFO] Copying jetty-servlet-9.0.6.v20130930.jar to .../simple-heroku-webapp/target/dependency/jetty-servlet-9.0.6.v20130930.jar
        [INFO] Copying javax.inject-2.2.0-b21.jar to .../simple-heroku-webapp/target/dependency/javax.inject-2.2.0-b21.jar
        [INFO] Copying javax.servlet-3.0.0.v201112011016.jar to .../simple-heroku-webapp/target/dependency/javax.servlet-3.0.0.v201112011016.jar
        [INFO] Copying javax.annotation-api-1.2.jar to .../simple-heroku-webapp/target/dependency/javax.annotation-api-1.2.jar
        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD SUCCESS
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 4.401s
        [INFO] Finished at: Mon Dec 09 20:19:06 CET 2013
        [INFO] Final Memory: 20M/246M
        [INFO] ------------------------------------------------------------------------

Now that you know everything went as expected you are ready to:

- make some changes in your project,
- take the packaged WAR (located under `./target/simple-service-webapp.war`) and deploy it to a Servlet container of your choice, or
- Section 1.5.1, “Deploy it on Heroku”

### Tip

If you want to make some changes to your application you can run the application locally by simply running `mvn clean package jetty:run` (which starts the embedded Jetty server) or by `java -cp target/classes:target/dependency/* com.example.heroku.Main` (this is how Jetty is started on Heroku).

### 1.5.1. Deploy it on Heroku

We won't go into details how to create an account on Heroku and setup the `Heroku` tools on your machine. You can find a lot of information in this article: Getting Started with Java on Heroku. Instead, we'll take a look at the steps needed after your environment is ready.

The first step is to create a Git repository from your project:

        $ git init
        Initialized empty Git repository in /.../simple-heroku-webapp/.git/

Then, create a Heroku instance and add a remote reference to your Git repository:

        $ heroku create
        Creating simple-heroku-webapp... done, stack is cedar
        http://simple-heroku-webapp.herokuapp.com/ | git@heroku.com:simple-heroku-webapp.git
        Git remote heroku added

### Note

The name of the instance is changed in the output to `simple-heroku-webapp`. Your will be named more like `tranquil-basin-4744`.

Add and commit files to your Git repository:

        $ git add src/ pom.xml Procfile system.properties

        $ git commit -a -m "initial commit"
        [master (root-commit) e2b58e3] initial commit
         7 files changed, 221 insertions(+)
         create mode 100644 Procfile
         create mode 100644 pom.xml
         create mode 100644 src/main/java/com/example/MyResource.java
         create mode 100644 src/main/java/com/example/heroku/Main.java
         create mode 100644 src/main/webapp/WEB-INF/web.xml
         create mode 100644 src/test/java/com/example/MyResourceTest.java
         create mode 100644 system.properties

Push changes to Heroku:

        $ git push heroku master
        Counting objects: 21, done.
        Delta compression using up to 8 threads.
        Compressing objects: 100% (11/11), done.
        Writing objects: 100% (21/21), 3.73 KiB | 0 bytes/s, done.
        Total 21 (delta 0), reused 0 (delta 0)

        -----> Java app detected
        -----> Installing OpenJDK 1.7... done
        -----> Installing Maven 3.0.3... done
        -----> Installing settings.xml... done
        -----> executing /app/tmp/cache/.maven/bin/mvn -B -Duser.home=/tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd -Dmaven.repo.local=/app/tmp/cache/.m2/repository -s /app/tmp/cache/.m2/settings.xml -DskipTests=true clean install
               [INFO] Scanning for projects...
               [INFO]
               [INFO] ------------------------------------------------------------------------
               [INFO] Building simple-heroku-webapp 1.0-SNAPSHOT
               [INFO] ------------------------------------------------------------------------
               [INFO]
               [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ simple-heroku-webapp ---
               [INFO]
               [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ simple-heroku-webapp ---
               [INFO] Using 'UTF-8' encoding to copy filtered resources.
               [INFO] skip non existing resourceDirectory /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/src/main/resources
               [INFO]
               [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ simple-heroku-webapp ---
               [INFO] Compiling 2 source files to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/classes
               [INFO]
               [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ simple-heroku-webapp ---
               [INFO] Using 'UTF-8' encoding to copy filtered resources.
               [INFO] skip non existing resourceDirectory /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/src/test/resources
               [INFO]
               [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ simple-heroku-webapp ---
               [INFO] Compiling 1 source file to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/test-classes
               [INFO]
               [INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ simple-heroku-webapp ---
               [INFO] Tests are skipped.
               [INFO]
               [INFO] --- maven-war-plugin:2.1.1:war (default-war) @ simple-heroku-webapp ---
               [INFO] Packaging webapp
               [INFO] Assembling webapp [simple-heroku-webapp] in [/tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/simple-heroku-webapp]
               [INFO] Processing war project
               [INFO] Copying webapp resources [/tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/src/main/webapp]
               [INFO] Webapp assembled in [88 msecs]
               [INFO] Building war: /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/simple-heroku-webapp.war
               [INFO] WEB-INF/web.xml already added, skipping
               [INFO]
               [INFO] --- maven-dependency-plugin:2.1:copy-dependencies (copy-dependencies) @ simple-heroku-webapp ---
               [INFO] Copying guava-14.0.1.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/guava-14.0.1.jar
               [INFO] Copying javax.annotation-api-1.2.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/javax.annotation-api-1.2.jar
               [INFO] Copying validation-api-1.1.0.Final.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/validation-api-1.1.0.Final.jar
               [INFO] Copying javax.ws.rs-api-2.0.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/javax.ws.rs-api-2.0.jar
               [INFO] Copying jetty-http-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-http-9.0.6.v20130930.jar
               [INFO] Copying jetty-io-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-io-9.0.6.v20130930.jar
               [INFO] Copying jetty-security-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-security-9.0.6.v20130930.jar
               [INFO] Copying jetty-server-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-server-9.0.6.v20130930.jar
               [INFO] Copying jetty-servlet-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-servlet-9.0.6.v20130930.jar
               [INFO] Copying jetty-util-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-util-9.0.6.v20130930.jar
               [INFO] Copying jetty-webapp-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-webapp-9.0.6.v20130930.jar
               [INFO] Copying jetty-xml-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-xml-9.0.6.v20130930.jar
               [INFO] Copying javax.servlet-3.0.0.v201112011016.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/javax.servlet-3.0.0.v201112011016.jar
               [INFO] Copying hk2-api-2.2.0-b21.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/hk2-api-2.2.0-b21.jar
               [INFO] Copying hk2-locator-2.2.0-b21.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/hk2-locator-2.2.0-b21.jar
               [INFO] Copying hk2-utils-2.2.0-b21.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/hk2-utils-2.2.0-b21.jar
               [INFO] Copying osgi-resource-locator-1.0.1.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/osgi-resource-locator-1.0.1.jar
               [INFO] Copying asm-all-repackaged-2.2.0-b21.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/asm-all-repackaged-2.2.0-b21.jar
               [INFO] Copying cglib-2.2.0-b21.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/cglib-2.2.0-b21.jar
               [INFO] Copying javax.inject-2.2.0-b21.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/javax.inject-2.2.0-b21.jar
               [INFO] Copying jersey-container-servlet-2.5.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jersey-container-servlet-2.5.jar
               [INFO] Copying jersey-container-servlet-core-2.5.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jersey-container-servlet-core-2.5.jar
               [INFO] Copying jersey-client-2.5.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jersey-client-2.5.jar
               [INFO] Copying jersey-common-2.5.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jersey-common-2.5.jar
               [INFO] Copying jersey-server-2.5.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jersey-server-2.5.jar
               [INFO]
               [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ simple-heroku-webapp ---
               [INFO] Installing /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/simple-heroku-webapp.war to /app/tmp/cache/.m2/repository/com/example/simple-heroku-webapp/1.0-SNAPSHOT/simple-heroku-webapp-1.0-SNAPSHOT.war
               [INFO] Installing /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/pom.xml to /app/tmp/cache/.m2/repository/com/example/simple-heroku-webapp/1.0-SNAPSHOT/simple-heroku-webapp-1.0-SNAPSHOT.pom
               [INFO] ------------------------------------------------------------------------
               [INFO] BUILD SUCCESS
               [INFO] ------------------------------------------------------------------------
               [INFO] Total time: 45.861s
               [INFO] Finished at: Mon Dec 09 19:51:34 UTC 2013
               [INFO] Final Memory: 17M/514M
               [INFO] ------------------------------------------------------------------------
        -----> Discovering process types
               Procfile declares types -> web

        -----> Compiled slug size: 75.9MB
        -----> Launching... done, v6
               http://simple-heroku-webapp.herokuapp.com deployed to Heroku

        To git@heroku.com:simple-heroku-webapp.git
         * [new branch]      master -> master

Now you can access your application at, for example: http://simple-heroku-webapp.herokuapp.com/myresource

## 1.6. Exploring Other Jersey Examples

In the sections above, we have covered an approach how to get dirty with Jersey quickly. Please consult the other sections of the Jersey User Guide to learn more about Jersey and JAX-RS. Even though we try our best to cover as much as possible in the User Guide, there is always a chance that you would not be able to get a full answer to the problem you are solving. In that case, consider diving in our examples that provide additional tips and hints to the features you may want to use in your projects.

Jersey codebase contains a number of useful examples on how to use various JAX-RS and Jersey features. Feel free to browse through the code of individual Jersey Examples in the Jersey source repository. For off-line browsing, you can also download a bundle with all the examples from here.

Prev |  | Next
Preface | Home | Chapter 2. Modules and dependencies