Tag Archives: REST

JAX-RS 2.0 and Jersey 2.0 released!

I’m very excited to announce that after 2+ years of prototyping, refactoring and development we have released the final version of both JAX-RS 2.0 API and Jersey 2.0 which provides Reference Implementation for JAX-RS 2.0.

Those of you, who followed my earlier updates know, that Jersey 2.0 has been heavily refactored to accomodate significant changes brought by JAX-RS 2.0, such as Client API, Filters and interceptors or Server-side async support. We have also decided to switch to git as our primary VCS which allowed us to move the project repository to GitHub. We hope that this move will make it easier for our community to browse through the code and contribute to the project via convenient pull requests.

What’s in?

For a complete overview of the Jersey 2.0 API, please have a look at the Jersey 2.0 API documentation. You may want to also bookmark the Jersey 2.x latest API documentation permalink to if you want to see the latest released version of the API in the future. Also feel free to browse Jersey 2 source code on GitHub and check out the Jersey examples. You may also want to check Jersey 2.0 User Guide. With so many changes, we have added a dedicated section on migrating your Jersey 1.x code to Jersey 2.0 that we will continue updating based on the questions that we receive in our user forum.

Jersey 2.0 provides support for Java SE HTTP Server, Grizzly 2 HTTP server, Servlet 2.5 or higher containers as well as OSGi containers on the server side and HTTPURLConnection-based or Grizzly asynchronous client transport connectors. To leverage JAX-RS/Jersey server-side async features in a Servlet container, you need a container that supports Servlet 3.0 at least. Jersey supports asynchronous resource invocations on Grizzly 2 HTTP server too.

If you are interested in more details about the work done as part of Jersey 2.0 release,  check out the Jersey 2.0 Release Notes.

Where to get?

All the Jersey 2.0 release binaries, including the source & apidocs jars, are available for download under the Jersey 2.0 maven root group identifier org.glassfish.jersey from the central maven repository as well as from the java.net maven repository.

To start with Jersey 2.0, downloading Jersey JAX-RS 2.0 RI bundle is a good start as the bundle contains the JAX-RS 2.0 API jar, all the core Jersey module jars as well as all the required 3rd-party dependencies. You may also want to download Jersey 2.0 Examples bundle for off-line browsing.

Chances are you are using Apache Maven as a build & dependency management tool for your project. If you do, there is a very easy and convenient way to start playing with Jersey 2.0 by generating the skeleton application from one of the Jersey 2.0 maven archetypes that we provide. For instance, to create a Jersey 2.0 application using the Grizzly 2 HTTP server container, use

mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-grizzly2 -DarchetypeVersion=2.0

If you want to create a Servlet container deployable Jersey 2.0 web application instead, use

mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeVersion=2.0

Where to ask?

Have fun looking around, running examples, testing new additions to the set of features and playing with Jersey 2. To provide feedback send us an email to our users mailing list

use...@jersey.java.net (archived here)

or log discovered bugs & new feature requests in Jersey Jira issue tracker.

What about Java EE 7?

As most of you have probably noticed, Java EE 7 platform has been released too. JAX-RS 2.0 is included in this enterprise Java platform release and as such Jersey 2.0 is included in Java EE 7 RI that is provided by GlassFish 4.0. This means that you can deploy your JAX-RS 2.0 applications to GlassFish 4.0 without having to worry about Jersey 2.0 dependencies.

Important note on Jersey 2.0 in GlassFish 4.0!

Unfortunately, in case you are playing with the GlassFish 4.0 release (build 4.0-b89) there is a task you may want to do in order to get the released Jersey 2.0 version installed in your GlassFish instance. The version of Jersey 2.0 bundled with the released GlassFish 4.0 (4.0-b89) and Java EE 7 SDK does not contain a fix for injection issues that you may experience when CDI, JAX-RS and other injection-aware technologies (e.g. BeanValidation) are used together in one project. While the issue has been fixed in the released Jersey 2.0 binaries, these fixed binaries were not picked by the final GlassFish 4.0 build due to some maven repository stale cache issues. Since we only found out about the issue a day before GlassFish 4.0 and Java EE 7 release, it was not possible to re-spin the build and have it fully tested for the release. I was told by the GlassFish team that they plan to release a new build soon which should contain the final Jersey version as well as any fixes for critical issues reported by the community.

Luckily, GlassFish comes with an Update Tool facility. So, until a new GlassFish build is released, to fix the problem with stale Jersey 2.0 modules, use the update tool to update your GlassFish installation to the released Jersey 2.0 by following these steps (thanks to Jakub for providing them):

  1. After unzipping/installing GlassFish 4.0, switch to the GlassFish installation root directory and launch the following command from the command line:
    ./bin/updatetool

    You should see the following output:

    The software needed for this command (updatetool) is not installed.
    
    If you choose to install Update Tool, your system will be automatically
    configured to periodically check for software updates. If you would like
    to configure the tool to not check for updates, you can override the
    default behavior via the tool's Preferences facility.
    
    When this tool interacts with package repositories, some system information
    such as your system's IP address and operating system type and version
    is sent to the repository server. For more information please see:
    
    http://wikis.oracle.com/display/updatecenter/UsageMetricsUC2
    
    Once installation is complete you may re-run this command.
    
    Would you like to install Update Tool now (y/n):
  2. Enter y (yes) to get the Update Tool software installed. You will see the following information (or similar):
    Proxy: Using system proxy settings.
    Install image: <path_to_your_glassfish_installation>/glassfish/4.0
    Installing pkg packages.
    Downloading 2 packages.
    Downloading pkg (510 files, 6,905,269 bytes).
    File 510/510
    Downloading python2.4-minimal (301 files, 8,608,973 bytes).
    File 301/301
    Executing 929 install actions.
    Installing updatetool packages.
    Downloading 2 packages.
    Downloading updatetool (571 files, 4,393,462 bytes).
    File 571/571
    Downloading wxpython2.8-minimal (298 files, 46,961,258 bytes).
    File 298/298
    Executing 1,030 install actions.
    Registering notifier: Successful.
    Starting notifier.
    Initialization complete.
    
    Software successfully installed. You may now re-run this command (updatetool).
  3. Once the installation finishes, launch the ./bin/updatetool command again – a GlassFish Update Tool window will pop up.
  4. Click on the “Available Updates” under your “GlassFish” application image in the left panel to verify that a newer version of Jersey 2.0 is available:Updating GlassFish 4.0 to Jersey 2.0
  5. Then, click on the big green arrow in the toolbar or right-click on the Jersey item in the list and select “Install Marked Components”. After accepting the license agreement, GlassFish Update Tool will automatically update the Jersey version in your GlassFish 4.0 installation to the correct, released version of Jersey 2.0. Once updated, you should see the “Jersey 2 Core,…” listed with the new version “2.0-0.2″ under “Installed Components”:GlassFish 4.0 updated to Jersey 2.0
  6. Enjoy :)

Note that you can use the process above in the future to update your GlassFish 4.0 installation with newer versions of Jersey 2.

Jersey 2.0-m09 has been released

With JavaOne 2012 over we are trying to resume the usual Jersey 2.0 release cycle and I am happy to announce that Jersey 2.0-m09 has been released. The last sprint was relatively short especially with all the additional distracting tasks we had to focus on prior to and during the JavaOne week. The number of significant updates in this release is thus moderate, yet there are couple of updates which I’d like to point out:

  • Migration to the JAX-RS 2.0 Public Review Draft API version. This was an important move so that people who want to play with JAX-RS 2.0 PR API during the currently running review period are able to grab an implementation compatible with the latest published version of the API. Note however that there are still some aspects of the latest JAX-RS API that are under development at the moment.
  • Again, lot of bug fixes. We continued to keep our focus on resolving bugs. We do this not only to improve stability of Jersey code as such but also to make sure we’re properly covering all aspects of the new JAX-RS 2.0 API features which in turn helps us verify the API works as intended. So as with previous milestone, many of the bugs that we have fixed recently were in the category of strict compliance to the JAX-RS 2.0 API and specification and often involved corner-case situations.

If you are interested in more details, check out the Jersey Jira for the list of all the resolved feature requests, tasks and issues in the milestone 09.

For a complete overview of the updates in the Jersey API, please have a look at the Jersey 2.0-m09 API documentation. Note that we are still in the middle of a development cycle and Jersey 2.0-m09 is an early development preview release so you can still expect significant changes in the API since the parts of the API are moving every now and then. You may want to also bookmark the Jersey 2.0 snapshot API documentation link to if you want to see the latest development version of the API. Also feel free to browse Jersey 2 source code on GitHub and check out the Jersey examples.

You may also want to check Jersey User guide that also contains an initial draft of a migration guide for your Jersey 1.x code.

Jersey 2.0 provides support for Java SE HTTP Server, Grizzly 2 HTTP server, Servlet 2.5 or higher containers as well as OSGi containers on the server side and HTTPURLConnection-based or Grizzly asynchronous client transport connectors. To leverage JAX-RS/Jersey server-side async features in a Servlet container, you need a container that supports Servlet 3.0 at least. Jersey supports asynchronous resource invocations on Grizzly 2 HTTP server too.

All the 2.0-m09 milestone binaries, including the source & apidocs jars, are available for download under the Jersey 2.0 maven root group identifier org.glassfish.jersey from the central maven repository as well as from the java.net maven repository.

To run Jersey 2 you’ll need the core artifacts:

org.glassfish.jersey.core:jersey-common
org.glassfish.jersey.core:jersey-server
org.glassfish.jersey.core:jersey-client

Additionally, you’ll need a Jersey container implementation, e.g. Jersey Grizzly2 HTTP container:

org.glassfish.jersey.containers:jersey-container-grizzly2-http

Chances are you are using maven on your project. If you do, there is a very easy and convenient way to start playing with Jersey 2.0 by generating the skeleton application from one of the Jersey 2.0 maven archetypes that we provide. For instance, to create a Jersey 2.0 application using the Grizzly 2 HTTP server container, use

mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-grizzly2 -DarchetypeVersion=2.0-m09

If you want to create a Servlet container deployable Jersey 2.0 web application instead, use

mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeVersion=2.0-m09

Have fun looking around, running examples, testing new additions to the set of features and playing with Jersey 2. To provide feedback send us an email to our users mailing list

use...@jersey.java.net (archived here)

or log discovered bugs & new feature requests in Jersey Jira issue tracker.

Jersey 2.0-m08 is out (and so is 2.0-m07…)

I’ve been pretty busy lately preparing JAX-RS 2.0 specification for a Public Review release as well as updating Jersey to accomodate recent JAX-RS 2.0 API changes in areas of server-side asynchronous API, client and URI builder API as well as some other minor changes. Preparing for my JavaOne presentations that’s just round the corner also took a significant chunk of my spare time. FYI, JavaOne 2012 is happening next week so if you wanted to go and you still don’t have your pass, you should get one now.

Anyway, so much for the excuses of why I’ve been quiet lately. Today I’d like to announce that we’ve recently released Jersey 2.0-m08. For those of you who watch my blog and wonder what happened to Jersey 2.0-m07, well, the good news is that we’ve released that one too about a month ago, the bad news is that I shamefully didn’t find enough time to blog about it. In any case, things move quickly, and Jersey 2.0-m07 is the past now so today I’ll be focusing on the latest milestone 08 release, however I’ll be cover all important changes between milestone 06 to milestone 08, including the features delivered in milestone 07 of Jersey 2.0.

Let’s look at the main changes now:

  • ResourceContext API (a similar one to the Jersey 1.x ResourceContext) has been introduced in JAX-RS 2.0 and support for it has been implemented in Jersey. Based on the feedback we received form JAX-RS 2.0 Expert Group, we decided to remove the resource and URI matching methods from the standard API and just keep the API focused on providing resource injection support independent of the underlying injection manager. You can now use the API with Jersey 2.0 to provision and/or inject your sub-resource instances in a standard way.
  • Support for application WADL generation. As it is possible in Jersey 1.x, Jersey 2.0 runtime now also supports automatically generate WADL descriptors for your JAX-RS applications.
  • Support for the new JAX-RS @BeanParam annotation. This injection annotation is a nice addition to the JAX-RS API that should help to make your resource method signatures more readable. See the linked annotation API documentation for more details.
  • Support for the revised JAX-RS asynchronous server-side API. The revamped JAX-RS async API looks much better, is more consistent and even simpler to use that the previous version. We managed to identify and drop some redundant pieces from the old API as well as add new interesting features such as callbacks and timeout handler in the new version of the API. Of course, this change meant that a significant effort had to be invested in refactoring the existing Jersey implementation. Now we’re proud to say that we made it. Jersey 2.0-m08 supports the new JAX-RS async API.
  • Performance and internal design improvements. In the last 2 milestones we started to focus more also on the performance side of Jersey 2.0. We have also identified a few design issues in the client as well as server-side runtime code that we addressed in order to improve the maintainability of Jersey code in the future. In other words, while as a user you may never notice it, the main difference between Jersey 2.0 milestone 06 and 08 is that the latest Jersey 2.0 milestone had undergone a major runtime engine overhauling and now runs better than ever. For instance, we ditched the idea of a common client & server, sync & async processing engine that suffered from high increase in code complexity over time. Instead, we introduced specific client and server side processing engines tailored for the specific needs of the client and server. Also, we now make sure that requests that do not involve any async processing use code paths optimized for synchronous executions that do not involve any thread context switching or other tasks specific for the asynchronous request processing.
  • Lot of bug fixes. And I mean really LOT of fixed bugs. In fact, the main theme of the milestone 08 was bug fixing to make sure the Jersey 2.0 is in the best possible shape to be used in JavaOne demos. Now I do not want you to think that Jersey 2.0 was not stable before. Many of the bugs that we have fixed recently were mostly in the category of strict compliance to the JAX-RS 2.0 API and specification and involved mostly corner-case situations. Still, it’s a good feeling to know that Jersey now much more precisely adheres to the spec much even in these rare use case scenarios.

If you are interested in more details, check out the Jersey Jira for the list of all the resolved feature requests, tasks and issues in the milestone 07 and milestone 08.

For a complete overview of the updates in the Jersey API, please have a look at the Jersey 2.0-m08 API documentation. Note that we are still in the middle of a development cycle and Jersey 2.0-m08 is an early development preview release so you can still expect significant changes in the API since the parts of the API are moving every now and then. You may want to also bookmark the Jersey 2.0 snapshot API documentation link to if you want to see the latest development version of the API. Also feel free to browse Jersey 2 source code on GitHub and check out the Jersey examples.

In the last sprint we also continued work on an updated user guide that also contains an initial draft of a migration guide for your Jersey 1.x code.

Jersey 2.0 provides support for Java SE HTTP Server, Grizzly 2 HTTP server, Servlet 2.5 or higher containers as well as OSGi containers on the server side and HTTPURLConnection-based or Grizzly asynchronous client transport connectors. To leverage JAX-RS/Jersey server-side async features in a Servlet container, you need a container that supports Servlet 3.0 at least. Jersey supports asynchronous resource invocations on Grizzly 2 HTTP server too.

All the 2.0-m08 milestone binaries, including the source & apidocs jars, are available for download under the Jersey 2.0 maven root group identifier org.glassfish.jersey from the central maven repository as well as from the java.net maven repository.

To run Jersey 2 you’ll need the core artifacts:

org.glassfish.jersey.core:jersey-common
org.glassfish.jersey.core:jersey-server
org.glassfish.jersey.core:jersey-client

Additionally, you’ll need a Jersey container implementation, e.g. Jersey Grizzly2 HTTP container:

org.glassfish.jersey.containers:jersey-container-grizzly2-http

Chances are you are using maven on your project. If you do, there is a very easy and convenient way to start playing with Jersey 2.0 by generating the skeleton application from one of the Jersey 2.0 maven archetypes that we provide. For instance, to create a Jersey 2.0 application using the Grizzly 2 HTTP server container, use

mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-grizzly2 -DarchetypeVersion=2.0-m08

If you want to create a Servlet container deployable Jersey 2.0 web application instead, use

mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeVersion=2.0-m08

Have fun looking around, running examples, testing new additions to the set of features and playing with Jersey 2. To provide feedback send us an email to our users mailing list

use...@jersey.java.net (archived here)

or log discovered bugs & new feature requests in Jersey Jira issue tracker.