Earthly Powers
- All
- Fast Infoset
- General
- Java
- REST
Jersey 1.0.3 is released
We have just released version 1.0.3 of Jersey, the open source, production quality, reference implementation of the JAX-RS 1.0 API. The JAX-RS specification is available at the JCP web site and also available in non-normative HTML here.
It will be available soon from the Glassfish v2 and v3 update centers.
To get started with Jersey read the getting started document. For an overview of JAX-RS features read the Jersey user guide. To understand more about what Jersey depends on read the dependencies document.
The following JavaDoc is available:
- Client, Server, Grizzly, WADL, JSON APIs.
- Spring integration API.
- Guice integration API.
- MIME Multipart API.
- Client using Apache HTTP client API.
- Atom with Apache Abdera API.
- Simple HTTP server integration API.
This release has many bug fixes, you can see the change log here, as well as the following improvements and features:
- Guice 2.0 integration, leveraging the contribution by Gili Tzabari. Guice integration is on a par with Spring integration.
The support depends on Guice 2.0 distributed in the GuiceyFruit maven repository. GuiceyFruit, developed by James Strachan, is a set of extensions to Guice 2.0, such as support for Java EE artifacts like @PostConstruct/@PreDestroy, @Resource and @PersistenceContext. Jersey combined with GuiceyFruit makes for a very interesting fruity combination. - Developer defined WADL-based resource classes, inspired by James
Strachan's use of WADL and Jersey MVC.
Injecting WadlApplicationContext enables access to the WADL JAXB representation for the application. - Multipart MIME improvements to the jersey-multipart module.
The parsing of Multipart MIME now uses the MIMEPull API which provides efficient stream-based processing and the caching of large MIME body parts to disk. Thus very large Multipart MIME may be consumed without running out of memory (as was previously the case).
The overloaded use of @FormParam with "multipart/form-data" body parts has now been deprecated as this caused much confusion and created an artificial and limited abstraction when processing form data. This has been replaced with @FormDataParam.
Finally Imran M Yousuf provided a number of useful fixes, tests and improvements, such as client-side uploading files with FileDataBodyPart. - Niall Gallagher contributed container support for the Simple HTTP server. This was an excellent contribution, code, tests and documentation, very easy to integrate.
- Enterprise session beans as resource classes.
Ken and I worked on integration with the latest builds of Glassfish as described here. - Client API listeners when producing/consuming representations.
Pavel added support via a filter to listen to the client sending and receiving representations, which is useful to present feedback when uploading or downloading files. See ConnectionListenerFilter. - Plug-in Java type support for @*Param annotations.
JAX-RS defines a set of rules (for example, see @QueryParam) but it is useful to support additional rules.
The JAX-RS rules are implemented using StringReaderProvider and developers may implement the same provider interface to add their own rules. Jersey provides support for java.util.Date (using the standard HTTP supported date formats) and JAXB for XML-encoded documents. - Pavel has added a sample showing how to use Jersey with HTTPs, client certificates and Grizzly.
- Jakub has created the maven infrastructure for a Jersey user guide (also available in PDF). Currently the user guide contains the JAX-RS overview (the same as presented on the Jersey wiki) and documentation on JSON support.
Documentation is important (and as one person said to me, no documentation, no feature) but it takes time for us developers to write English prose, so the user guide will be developed iteratively. Contributions to this area are most welcome. - Naresh's Jersey test framework has been included and some samples are already using it. We plan to transition over the other samples and may make breaking changes to the test API as we improve support.
The next release, 1.1.0-ea, is scheduled for the end of April 2009. This will be an early access implementation of the JAX-RS 1.1 maintenance release. We will be calling it "early access" because not all EE features will be ready until the full EE 6 implementation is available in the final release GlassFish v3. However, developers can still expect the same degree of quality as that for previous releases of Jersey.
For feedback send email to:
users@jersey.dev.java.net (archived here)
or log a bugs/features here.
Posted at 11:11AM Apr 16, 2009 by Paul Sandoz in REST | Comments[7]
Jersey and Spring enterprise tech tip
An new enterprise tech tip explaining how to get started with Jersey and Spring is available.
Additionally, see here for JavaDoc and here for a Spring sample.
Posted at 10:06AM Apr 14, 2009 by Paul Sandoz in REST | Comments[0]
Jersey features and documentation
There are a whole bunch of features that Jersey provides in addition to the JAX-RS API. Here are some of the main features:
- WADL
A WADL can be obtained from the running service for the known resources at deployment or for each resource using OPTIONS.
Documentation can be connected with the WADL.
The WADL runtime-model can be used in conjunction with the Model View Controller pattern. - Client API
Ease of use API for making request to HTTP-based services. Leverages artifacts of JAX-RS for producing and consuming representations as Java types.
Leverages existing HTTP client solutions like Http(S)UrlConnection or the Apache HTTP client. - Spring integration
This is also provided by NetBeans 6.5, see the Web services example for RESTful Web services and Spring.
Stay tuned for an enterprise tech-tip on Jersey & Spring. - Web application and resource-specific filtering
Resource-specific is how the @RolesAllowed support is implemented. - Model view controller with supported provided for JSPs.
A resource class is a controller, which can return a Viewable that references a view and a model. The view processed the model to render a representation such as an HTML page.
Developers can plug in support for their own view technology, say for Freemarker or Velocity, by implementing a template processor. - JSON support integrated with JAXB
Use one annotated JAXB class instances of which can be serialized to XML or JSON. - Multipart MIME ("multipart/*")
Makes it easier to consume "multipart/form" representations sent from browsers. - Atom support using Apache Abdera
See also the three samples: server; client; and model. - Embedded container support for monster a.k.a Grizzly and the light wight HTTP server (The Simple container will be available for 1.0.3)
See here for Grizzly.
Grizzly makes it really easy to test clients and services. - Plug-in injection support
Add your own stuff to be injected. See here and here. - Plug-in IoC-framework support
This framework is used to integrate Spring, Guice and EJB support. - Numerous samples
See here for a zip of all the samples.
Most of these features, and many others, have corresponding documentation in the JavaDoc but we realize this is not sufficient for developers.
With that in mind we have started work on a Jersey users guide, written in DocBook. Jakub has put some nice maven-based DocBook infrastructure in place and we can deploy the users guide to the maven repo.
I have converted the JAX-RS overview, on the wiki, to be a chapter of the users guide. And, Jakub is currently working on some JSON documentation. For a preview see the PDF and the HTML zip. We will slowly build up the users guide over successive iterations/releases.
Let is know what you think. And if you are interested in helping out in this documentation effort please email the Jersey users list: users@jersey.dev.java.net
Posted at 02:36PM Apr 03, 2009 by Paul Sandoz in REST | Comments[0]
NetBeans 6.7 m3, maven and Jersey
NetBeans 6.7 milestone 3 has support for maven web projects with RESTful Web services using Jersey:

Posted at 01:25PM Apr 03, 2009 by Paul Sandoz in REST | Comments[0]
Glassfish v3, EJB 3.1 and Jersey
With Glassfish V3 promoted build 43 (or greater) and the latest Jersey 1.0.3-SNAPSHOT it is now possible to create no-interface-view session beans (or POJO session beans) deployed in the war and those beans may be either (root) resource or provider classes.
A big thanks to Ken Saks who provided the hooks in the Glassfish EJB module so Jersey can dynamically plug-in if Glassfish EJB support is available.
For example one could develop the following root resource class:
@Stateless @Path("ssb") public class StatelessSessionRootResource { @Context private UriInfo ui;@GET public String get() { return "GET: " + ui.getRequestUri().toASCIIString(); } }
Notice the annotated field, ui, to obtain an instance of UriInfo. Jersey will defer to JNDI to obtain an instance of the session bean (using the EJB 3.1 portable naming mechanism) and the EJB module will inform Jersey when an instance of the session bean is constructed so that Jersey gets a chance to inject Jersey/JAX-RS artifacts.
Session beans can also be used for sub-resources. For example one can add another resource class:
@Stateless
public class StatelessSessionResource {
@Context private UriInfo ui;
@GET
public String get() {
return "GET: " + ui.getRequestUri().toASCIIString();
}
}
and then modify the StatelessSessionRootResource class to be as follows:
@Stateless @Path("ssb") public class StatelessSessionRootResource { @Context private UriInfo ui; @GET public String get() { return "GET: " + ui.getRequestUri().toASCIIString(); } @EJB StatelessSessionResource r;@Path("sub") public StatelessSessionResource getSub() { return r; } }
A reference to StatelessSessionResource is injected onto the root resource class and then the sub-resource locator method, getSub, returns that reference.
Alternatively the same functionality can be achieved using the Jersey specific feature of returning the class:
@Path("sub/class")
public Class<StatelessSessionResource> getSubClass() {
return StatelessSessionResource.class;
}
See here for a simple maven project, which contains the resource classes presented above, and can be built to create a war file to deploy to Glassfish V3. The following URIs will exercise the application:
http://localhost:8080/ejb-1.0/rs/ssb
Posted at 01:44PM Apr 02, 2009 by Paul Sandoz in REST | Comments[3]
JavaOne and CommunityOne sessions and BOFs
Thankfully JavaOne 2009 is a little later this year, 2nd to 5th of June. Which gives my co-speakers and I more time to prepare (or at least more time to leave things until something needs to be done!).
Three talks have been accepted:
- Technical session TS-4875.
Developing RESTful Web Services with the Java™ API for RESTful Web Services (JAX-RS). Marc Hadley, Paul Sandoz. - BOF-4878.
Developing RESTful Web Services with Jersey and Java™ API for RESTful Web Services (JAX-RS). Craig McClanahan, Jakub Podlesak, Paul Sandoz. - BOF-5009.
Atmosphere: Comet for Everyone, Everywhere. Jean-François Arcand, Paul Sandoz.
For BOF-4878 Craig will provide some interesting details on how Jersey is being utilized in Sun's Cloud offerings.
Atmosphere, although a young project, is already starting to get some good adoption. Atmosphere provides portable ease of use APIs to support Comet-style interactions. BOF-5009 will introduce Atmosphere and we will demonstrate using Atmosphere combined with Jersey.
If you plan to attend JavaOne and any of these sessions please contact me at Paul.Sandoz@Sun.Com and i can send you a special priority code you can utilize when registering.
For CommunityOne West one session has been accepted:
- Session S304228. Developing RESTful Web Services with JAX-RS and Jersey.
Posted at 10:40AM Apr 01, 2009 by Paul Sandoz in Java | Comments[1]
