Work begins on JAX-RS 2.0
Over the years the adoption of REST as an integration architecture outside of the Web has grown, so it was inevitable that Java and Java EE would be graced with a suitable standard, which was JSR 311, or more often called JAX-RS. This was finalised in 2008 and became part of EE6. Now over that time there have been several implementations, including the mandatory reference implementation. Many Java developers have found JAX-RS a benefit, though of course there have been the inevitable discussions about whether or not JAX-RS is RESTful.
However, as with most good standards, implementation experience is now being fed back into JAX-RS, with Roberto Chinnici of Oracle (ex Sun), recently announcing ...
Below you'll find a draft of the JAX-RS 2.0 JSR. Since JAX-RS 1.1 closed, we've been interacting with many of you in the community, at conferences and across various forums, so hopefully you won't find any surprising items in this draft. Please send us your comments/suggestions in the next couple of weeks. In parallel, we'll be working on filling in the remaining sections marked as TBD, including the schedule and business terms. We'd like to submit the JSR in early December, so as to get it approved by the JCP Executive Committee ahead of the year-end holidays.
Some highlights from the proposals include:
- The most commonly requested feature for JAX-RS 2.0 is a client API: many if not all JAX-RS implementations provide some degree of client API support. This JSR will define two client APIs, both compatible with the REST style: a low level API using a builder pattern and a higher level one leveraging the former.
- Model-View-Controller (MVC) is a common pattern in Web frameworks, where it is used predominantly by HTML-based applications. Adopting the MVC terminology, JAX-RS resource classes are comparable to controllers. This JSR will specify an MVC architecture compatible with the JAX-RS programing model. Java Server Pages will be specified as one type of view. It will be possible to plug in other view technologies, for example FreeMarker or StringTemplate.
- JAX-RS 1.1 was defined before JSR-330 was specified and as a result does not utilize 330 annotations, such as @Inject, as effectively as it could. This JSR will specify closer integration with 330 annotations that may potentially render some existing annotations in JAX-RS, such as @Context, deprecated or redundant.
- JAX-RS 1.1 defines a synchronous request response model on the server side. This JSR will specify a simple asynchronous request processing model such that a response can be returned asynchronous to the request. Servlet 3.0 can be leveraged to enable such support but implementations may choose to use other container-specific APIs instead.
Stefan Tilkov, has announced support of the new proposal, and Jerome Louvel, lead developer of the Restlet framework, is also supportive, but raises concerns about the TCK:
My main concern is about TCK access for open source projects such as the Restlet Framework (http://www.restlet.org). Despite several requests (including via the JCP scholarship program), we never got access to the TCK. Could you make clear upfront what will be the business/license terms for implementations of JAX-RS 2.0 distributed under open source licenses?
Bill de hÓra, one of the members of the original expert group, is also in agreement and provides the most feedback so far, including:
One practical problem I've seen is that real world systems don't always return errors in the same format as requested by the client (assuming the app developer requested anything at all, again common). Simple example - tomcat/jetty throwing up html error pages. We can argue this is quality problem with the server but it's ugly on clients when it happens and the entity binding blows up. I'd like to see something that echoes the exception mapper on the server side of JAX-RS. Another possibility is allocating handlers onto response codes.
Roberto asks for comments and suggestions relatively soon because, as he says "We'd like to submit the JSR in early December, so as to get it approved by the JCP Executive Committee ahead of the year-end holidays." So are there other things that need considering in JAX-RS 2.0?
MVC
by
serge boulay
This actually makes a lot of sense IMO. I think JSF 2.0 has made many fine improvements but I still think that there will be many people that will never identify with it. In part, because of their past experience with it and in part because they would rather use an "action" based framework (with the JavaScript framework of the day) over a "component" based framework. I'm sure there are many other reasons for not choosing JSF as a web framework; all this to say that there needs to be some standard MVC type framework (controller mainly) that is an alternative to JSF on the EE platform. In a similar vein, Microsoft has created asp.net MVC as an alternative web framework to asp.net. I think making JAX-RS easier to use as an MVC type framework will be a great alternative for those who don't want to use JSF.
oData is a sensible client API
by
Faisal Waris
•The most commonly requested feature for JAX-RS 2.0 is a client API: many if not all JAX-RS implementations provide some degree of client API support.
My suggestion would be to adopt Open Data Protocol (www.odata.org/). Lets not reinvent if we don't have to.
Re: oData is a sensible client API
by
Stefan Tilkov
Re: oData is a sensible client API
by
Jean-Jacques Dubray
a client API? MVC? I must be dreaming?
Re: oData is a sensible client API
by
Stefan Tilkov
Re: oData is a sensible client API
by
Jean-Jacques Dubray
Re: oData is a sensible client API
by
Stefan Tilkov
Re: oData is a sensible client API
by
Jean-Jacques Dubray
Re: oData is a sensible client API
by
Stefan Tilkov
Re: oData is a sensible client API
by
Jean-Jacques Dubray
Far more that those 4 points
by
William Martinez
Client API is a must, but still the server side feels like a set of marshalling/serializing, URL to method mapping, servlet spec in annotations thing.
A couple of weeks ago I read a comment where some guy confused a RESTFull service with a method in Java that I call encoding in the URL the method specs. If JAX-RS gives that impression, should be improved to semantically avoid those interpretations.
The goal is an spec about a framework for building RESTFul services in Java, but I feel it still needs more work to achieve that, like defining a service in the first place.
Cheers.
Re: oData is a sensible client API
by
William Martinez
Funny to read you both. Reminds me of two brothers that love discussing and usually disagree, but actually like each other.
Client API (or should I say Client side framework), would be very difficult. Nothing related to uniform interface, as it is not about a client that offers connectivity at that level. It may be more related to HATEOAS and App semantics.
Still, yes, the client may be just an HTTP hiding wrapper for the JAVA language, that based on other APIs, will create a Stub and perform method invocation (RPC mapping again). Let's hope it is not that.
Cheers
Client API plus
by
Cristian Ebbens
Re: Client API plus
by
Raymond Feng
For example, calling the following method will generate a HTTP request to invoke the REST service:
@Produces("application/xml")
Customer getCustomer(@QueryParam("id") String id);
Tuscany SCA can inject the proxy to the client component. People may take this a "RPC" style, but it really simplifies the client code, IMO.
Thanks,
Raymond
Re: Client API plus
by
Jean-Jacques Dubray
I have made a proposal a while back for a RESTful client programming model here using an Xtext based DSL in response to Stefan finally admitting that "OO is pretty much a barrier to RESTfulness":
www.ebpml.org/blog2/index.php/2010/07/08/mde-be...
but what do I know?
I think I am missing something
by
Boris Lublinsky
As a foundation for client APIs you are proposing not a language independent interface definition (Yes, I am stopping short of using the W word), but rather Java interface. This will effectively leads to morphing REST into RMI with expensive protocol and marshaling. I understand that this is JAX-RS, but what about poor bastards that are using other languages, like C#, JavaScript, etc.
It also means throwing away many good things, for example loose coupling. In this approach it is slightly less coupled then RMI, but coupled enough.
Another topic is adding MVC to JAX-RS. I doubt it really makes a lot of sense. I was always fighting developers that where trying to merge business logic implementation with protocol implementation. The rational was always that interfaces come and go, while business implementation stays. Merging JAX-RS with MVC will inevitably lead to bleeding of some business logic into interface implementation
Re: oData is a sensible client API
by
Juergen Brendel
I think this sort of built-in, automatic generation of meta data / documentation about a resource is very helpful, especially once you have APIs where even users can create new resources. In that case, it's actually pretty much mandatory that the system documents itself and stays up to date.
Currently, we are working on moving some of the RESTful concepts we explored with RESTx into the Mule ESB.
Re: oData is a sensible client API
by
Jean-Jacques Dubray
>> by having the documentation generated automatically by the server. ...
>> Metadata ... this sort of built-in, automatic generation of meta data /
>> documentation about a resource is very helpful
you must be kidding me, a small group of people sold us REST in 2007 as being the technology that didn't need any kind of code / documentation generation because this was brittle. What's next? are you also going to generate code?
@Boris, I guess some of the RESTafarians have no (Java Server) face.
Re: I think I am missing something
by
William Martinez
Building Client APIs support seems like a good idea (although this contradict to initial REST claims, that REST is better than WS, because it does not require heavy frameworks)
Actually, wrong claim. First because WS and REST has almost nothing in common. REST is not for services (originally, let's say) and now that is used to construct services in web, of course it will need a little help.
As a foundation for client APIs you are proposing not a language independent interface definition (Yes, I am stopping short of using the W word), but rather Java interface.
That makes sense since this is a Java helper. Now, you can use the server side and use any language for the client. A Java framework for the client side will simplify the use of the REST interface, but should not be coupled. That is, I cannot, in any way, make that java client the only one able to use the Jax-RS server api.
This will effectively leads to morphing REST into RMI with expensive protocol and marshaling. I understand that this is JAX-RS, but what about poor bastards that are using other languages, like C#, JavaScript, etc.
Totally agree. As JAX-RS tries to leverage Java language, particularly objects, into REST, the final result is a Forced Paradigm Antipattern instance (blogginh about it, not time to post now), where you end up with RMI if no care is taken.
Another topic is adding MVC to JAX-RS. I doubt it really makes a lot of sense. I was always fighting developers that where trying to merge business logic implementation with protocol implementation. The rational was always that interfaces come and go, while business implementation stays. Merging JAX-RS with MVC will inevitably lead to bleeding of some business logic into interface implementation
This sounds very logical to me. Agree it should be discussed further.
William Martinez Pomares.
Re: oData is a sensible client API
by
Juergen Brendel
Specifically, the 'generated documentation' is merely a different representation of the resource: A real-time view of the resource's meta data. It's not generated documentation in the conventional sense. The meta data contains enough information to be suitable as documentation and which is also machine readable, contains links to follow, etc.
We need to simplify
by
Simon S.
Let's keep the latter for the guys that like
- binding contracts
- client/server code generation
- concurrent client/server development
- protocol abstraction
and the former for the ones who can do without the above and want to have it the easy way.
REST is so beautiful, it would be bad have a complicated api to implement it in java.
Educational Content
Large-Scale Continuous Testing in the Cloud
John Penix May 24, 2013
Managing Build Jobs for Continuous Delivery
Martin Peston May 24, 2013
Clojure in the Field
Stuart Halloway May 23, 2013




Hello stranger!
You need to Register an InfoQ account or Login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think