RESTful Java with JAX-RS

Errata for RESTful Java with JAX-RS

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date Submitted
PDF Page xix
middle of page, link to oreilly web page

The page contains: We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at: But that URL contains NO links to the code examples. Could you please post the code examples and build.xml or pom.xml files. Thank you.

Chris Joakim  Dec 23, 2009 
Printed Page page 31-35
inside code

From page 31-35, inside code, everywhere using 'throw new WebApplicationException(Response.Status.NOT_FOUND)' or 'throw new WebApplicationException (e, Response.Status.BAD_REQUEST)' causes error message 'cannot find symbol.. constructor WebApplicationException('. I am using NetBeans 6.8 and jsr311-api.jar.

Anonymous  Aug 11, 2010 
Printed Page page 82
line 12 from the bottom

Inside the block code of JSON, "," is missing after "married" : true

Anonymous  Aug 12, 2010 
Printed, Safari Books Online Page 1

There does not seem to be any link to download the sample code. There is a reference on the O'Reilly web site for the book "Download Example Code" but that takes you to the JBoss RESTEasy site, and there is no where to download the code for the examples in this book. Please let me know asap where I can find this Thanks!

Victor Grazi  Jun 01, 2011 
Safari Books Online 2
Chapter 8 - Building and Invoking Requests

The following code will give a compiler error because of the "accept()" method. The method "request()" is missing. It should precede "accept()". Customer customer ="") .accept("application/json") .get(Customer.class); List<Customer> customer ="") .accept("application/xml") .get(new GenericType<List<Customer>>() {});

Hani Ezzadeen  Dec 02, 2013 
Safari Books Online 4
request example code

- GET /resteasy/index.html HTTP/1.1 + GET /resteasy HTTP/1.1 "/resteasy/index.html" returns "HTTP/1.1 404 Not Found". You should use "/resteasy" to get correct "HTTP/1.1 200 OK" response.

Grzegorz Szpetkowski  Jan 26, 2011 
Other Digital Version 4


Guillermo Suchicital  Dec 12, 2011 
Printed Page 5
1st paragraph

the web address "" does not work.

David Levinson  Feb 11, 2013 
Other Digital Version 17

The footnote includes an URL for more information about Atom. The URL is wrong. Instead of it should read .

Anonymous  Feb 01, 2012 
PDF Page 18
3rd XML block

Customer id is defined as 771 on page 17 and that same customer's id is 117 on page 18.

Mark Fitzpatrick  Dec 12, 2009 
Safari Books Online 22
Second XML example.

In the client response XML where a new order is created, the order element has the id attribute set to "233". But the link element below contains the URI to "". Shouldn't this URI refer to the same order number as above?

HowardMc  Dec 06, 2009 
Printed Page 22
second XML fragment on page

The order id is 233, but the self-referencing URI says 133. <order id="233"> <link rel="self" href=""/> <total>$199.02</total> <date>December 22, 2008 06:56</date> ... </order>

Tony Childs  Feb 23, 2010 
Printed Page 22 & 23
line 19

On page 22, in 2nd block of messages, HTTP/1.1 201 Created Content-Type: application/xml Location: <order id="233"> <link rel="self" href="" /> ..... In the <link...> element, "133" should be "233". Is it correct? Similar issue at the top of page 23, in the <product id="111" > "111" should be "232". correct?

Anonymous  Aug 10, 2010 
Printed Page 22
Sample code, responce from POST

Minor typo. ... <order id="233"> <link rel="self" href="" /> ... I think the number on link should be 233, the same as returned order number.

Anonymous  Nov 14, 2011 
Printed Page 22
United States

The link element in the HTTP response message provides a URI whose implied ID (133) conflicts with the id attribute of the order element (233) and the implied ID in the Location header (233).

Dennis Mitchell  Nov 14, 2012 
Printed Page 23
xml listing at top of page

The uri request indicates a put /orders/232 But the post data indicates a product is being updated not an order and the id is 111.

PWRDWNSYS  Feb 03, 2010 
Printed Page 25
2-4 paragraph

I found the discussion of the "purge" operation interesting, yet I felt that there were other, less "forced" ways of doing the same thing. For instance, rather than creating a "purge" operation why not get all cancelled orders... GET /orders?cancelled=true HTTP/1.1 ...and iterate through them calling DELETE on each one. DELETE /orders/x HTTP/1.1 Even better why not just delete only canceled orders like so: DELETE /orders?cancelled=true HTTP/1.1 Granted that looks a lot like your "overloading DELETE" example, but it's different in one important way. It does not really overload the DELETE operation, but rather filters the resources that are being deleted. I would really like to hear your thoughts on this if you have time. Thanks, Tony Childs

Tony Childs  Feb 23, 2010 
Printed Page 33
1st paragraph - updateCustomer() method

The update of user "current" properties is non-atomic. This can lead to user "current" to contain data from two request (if the requests are parallel and a context switch occurs after the first request has copied some but not all of the properties). I would use customerDB.put(update.getId(), update) instead of copy each property.

Anonymous  Jan 19, 2010 
Printed Page 33
last paragraph

typo in the reference to method getcustomer() in the first sentence of the paragraph "Utility methods", should be getCustomer().

dominik.gruntz  Apr 05, 2010 
PDF Page 40
2nd paragraph

The text says that "If your application server is JAX-RS-aware or, in other words, is tightly integrated with JAX-RS, we can declare our ShoppingApplication class as a servlet". I'm using Glasfish V3, which is a JAX-RS-aware application server, but the Application subclass was not recognized as a servlet. Instead, it produces the error below: java.lang.ClassCastException: cannot be cast to javax.servlet.Servlet I believe this is a particularity of each application server and cannot be generalized.

Hildeberto Mendonça  Mar 21, 2010 
Printed Page 40
Second example

The second example is supposed to apply to application servers that are not JAX-RS aware. In dropping this into a Tomcat6 server with jsr311-api-1.1.jar, the com.jaxrs.vendor.JaxrsVendorServlet is reported as not found. I can't find any mention of this class in the book or any reference to it on the web except in pages that reference this book. Some explanation of what this class is and how to obtain it would be immensely helpful.

Todd Grigsby  Mar 02, 2011 
Printed Page 43
1st paragraph

@DELETE was not explained until page 43. But in page 43 1st paragraph. It is mentioned that we have covered @DELETE has been covered before page 43. It could be that @DELETE needs to be explained before page 43 or the mention in page 43 may be corrected. This is not a serious problem, still I felt that it can be corrected.

@DELETE not explained before page 43  Jan 25, 2012 
Printed Page 43
3rd paragraph

It says in Chapter 3 we saw "CustomerService" and "getAllCustomers". Really? Were you talking about a different book?

Dave Levinson  Feb 24, 2013 
PDF Page 43
1st paragraph

The third sentence states: "You also saw how we used the @Path annotation to bind a URI pattern to a Java method." I believe it should state: "You also saw how we used the @Path annotation to bind a URI pattern to a Java class." This is the code segment that it refers to. @Path("/customers") public interface CustomerResource {

Kurt Sanders  May 03, 2013 
PDF Page 47
Middle of the page

At the top of the Regular Expressions section, the regular expression for only decimals was given as: @Path("{id : \\d+}") But I think just \d+ is correct (the double-backslash ends meaning a literal backslash, not what is wanted here.)

Anonymous  Dec 06, 2010 
Printed Page 80
Source code at top of page

In the JAXB code example at the top of the page, the last line of code should have a cast to Customer class. Replace customer = ctx.createUnmarshaller().unmarshall(new StringReader(custString)); With customer = (Customer) ctx.createUnmarshaller().unmarshall(new StringReader(custString));

Chad Darby  Oct 14, 2010 
Printed Page 82
line 6-7

The sentence "If it is, it returns null; otherwise, it returns the JAXBContext..." should be written as "If it is, it returns the JAXBContext....; otherweise, it returns null".

dominik.gruntz  Apr 05, 2010 
Printed Page 83
Rule #4

The JSON mapping for "name" appears to be incorrect, at least according to rule #1. Change this: "name" : "Bill Burke" To this: "name" : { "$" : "Bill Burke" }

Bill Mc  Jan 17, 2012 
Printed Page 92
2nd List

- Return ctx.createUnmarshaller().unmarshal(outputStream); + return ctx.createUnmarshaller().unmarshal(entityStream);

Anonymous  Apr 17, 2010 
Printed Page 100
1st paragraph and followd list

ResponseBuilder.cookies() is not found on Response.ResponseBuilder class but cookie() method.

Anonymous  Apr 22, 2010 
Printed Page 100
2nd List

- NewCookie cookie = new NewCookie("key", "value); + NewCookie cookie = new NewCookie("key", "value");

Anonymous  Apr 22, 2010 
Safari Books Online 102 code example

- return Response.ok(entity); + return Response.ok(entity).build(); erroneous line returns ResponseBuilder object whereas method declaration expects it to be Response object. If you think I've contributed in a good way please send me a complimentary copy of the book. Thanks

Farooq Karim  Jan 24, 2011 
Printed Page 111
getSomething() method body, 1st line

Declaration of "variants" local variable should read as follows: List<Variant> variants = new ArrayList<Variant>();

Jean-François Morin  Mar 30, 2011 
Printed, Safari Books Online Page 111
United States

Starting on page 111, there are a series of examples that invoke a single-argument constructor for MediaType. I have checked the documentation for both JAX-RS 1.0 and 1.1 and in both cases it seems pretty clear that there are no single argument constructors.

Dave Blickstein  Jan 03, 2013 
Printed Page 112
several places

Several places on pages 112 and 113 refer to a "VariantBuilder" class. This should, I believe, be "VariantListBuilder"

Anonymous  Jan 28, 2010 
Printed, Safari Books Online Page 112
United States

An example that starts at the bottom of p 112 and continues onto p. 113 1) creates a VariantBuilder, 2) adds MediaTypes, 3) adds languages, 4) adds encodings 5) does a This will generate an empty List of Variants. I examined the source code (for Jersey 1.3 implementation at least) and it is clear from that that you need to introduce an add() sa all build does is return any variants that were add via the overloaded add methods. Put another way, the add methods are the ONLY methods that actually generate variants and adds them to the internal list. Thus just invoke build w/o an add, will generate an empty list.

Dave Blickstein  Jan 03, 2013 
Printed Page 116
3rd paragraph

The first sentence in third paragraph "... the schema allows for adding any arbitrary attribute to the id attribute." should be "... for adding arbitrary attribute to the customer element."

Anonymous  Feb 15, 2011 
Printed Page 127
5th list

- UriBuilder builder = UriBuilder.fromClass(CustomerService.class); + UriBuilder builder = UriBuilder.fromResource(CustomerService.class);

Anonymous  May 02, 2010 
Printed Page 132
bottom of the page

There are some errors. The Expires header value is GMT, so it should set TimeZone for Calendar's factory method. And Calendar#set doesn't return Date instance. So the correct list should be: Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.set(2010, 5, 15, 16, 0); builder.expires(cal.getTime());

Anonymous  Apr 24, 2010 
Printed Page 136
middle of the page (overall line 19)

When a service receives this GET request, it tries to match the current ETag hash of the resource with the one provided within the If-Modified-Since header. This should be the "If-None-Match header".

dominik.gruntz  Apr 05, 2010 
Printed Page 137
3rd paragraph

Since there is no definition of the header variable "If-Not-Modified", it should be "If-Modified-Since" or "If-Unmodified-Since".

Anonymous  Apr 24, 2010 
Printed Page 152
14th line from bottom

The CustomerResourceBean class declaration should read "public class CustomerResourceBean " instead of "public clas CustomerResourceBean ".

Jean-François Morin  Apr 13, 2011 
Printed Page 157
GET expample

- uri="/customer/333" + uri="/customers/333"

Anonymous  Apr 29, 2010 
Printed Page 158
the first and second list

The response attribute is md5 of (md5 of credential) and nonce and cnonce and (md5 of uri). So the first list must response = md5(H1 + "nonce:nc:cnonce:qop:" + H2); The list looks as H1 and H2 are literal.

Anonymous  Apr 29, 2010 
Printed Page 166
1st list

- connetion = (HttpURLConnection) getUrl.openConnection(); + connetion = (HttpURLConnection)url.openConnection();

Anonymous  May 07, 2010 
Safari Books Online 170

change "throw new RuntimeExceptioin" to "throw new RuntimeException" Also I think that this listing needs more imports e.g. class HttpGet requires: import org.apache.http.client.methods.HttpGet; and DefaultHttpClient requires: import org.apache.http.impl.client.DefaultHttpClient; Also there is something wrong with this code: InputStreamReader(response.getEntity().getInputStream())); I think there should be: InputStreamReader(response.getEntity().getContent())); Javadoc tells me that there is no getInputStream() method for HttpEntity interface, and correct method is getContent(). It was tested on HttpClient 4.0 and 4.0.1 (from with Oracle JDK6. Finally my imports looks: import*; import org.apache.http.*; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; Regards, Greg

Grzegorz Szpetkowski  Jun 22, 2010 
Safari Books Online 171
first paragraph

"In Apache HttpClient 4.x, the org. apache.http.client.DefaultHttpClient class is responsible for managing HTTP connections." I think there should be org.apache.http.impl.client.DefaultHttpClient (according to Javadoc from

Grzegorz Szpetkowski  Jun 22, 2010 
Printed Page 176
Not On the Book I tried to download page 176 sample using the above link. However, when I click on Download Example Code. It brought me to Please kindly modify the link so that I can learn how to get it from Customer.class. Thanks

Anonymous  Nov 19, 2012 
Printed Page 178
line 12, second code sample

In the sample code I see the statement "Response response = createCustomer(newCust)". I assume, that the createCustomer method has to be called on the generated proxy, i.e. "Response response = client.createCustomer(newCust)".

dominik.gruntz  Apr 05, 2010 
Printed Page 190
first code sample

the embedded server is not started. As printed, the code will throw a NullPointerException as server.getDeployment().getRegistry() is null.

dominik.gruntz  Apr 05, 2010 
Printed Page 192
3rd paragraph

In the paragraph about GZIP compression, the author refers to chapter 10. However in chapter 10 (Scaling JAX-RS Applications) there is nothing mentioned about compression. Is this piece missing from chapter 10, or is it just a mistake to refer to chapter 10?

Wim Praet  Feb 17, 2011 
Printed Page 198
bottom 2 urls

the 2 url's at the bottom of this page do not exist. And there is no indication of what should be referenced instead.

Anonymous  Apr 15, 2012 
Printed, Safari Books Online Page 201
6th paragraph

Perform the build by typing maven install. Maven uses pom.xml to figure out what to compile, build, and run the example code The correct command is "mvn install", not "maven install"

Victor Grazi  Jun 01, 2011 
Safari Books Online 216

In the example source code for ex04_3 The CustomerResource class has the added constructors that would be needed if not doing fully dynamic dispatching. The CustomerDatabaseResource class in the example also does not have the locateCustomerResource(String db) method, which I believe would have used the added CustomerResource constructor that accepts a Map<Integer, Customer>

Ken Branco  Feb 02, 2013 
Printed Page 224
2nd List

The cookie created at #createCustomer is indexed by "/" path, but the cookie referrenced at #getCustomers is indexed by "/rest/customers", so the paragraph on P.226 "If you refresh this page, you will see ..." is wrong. Need changing the cookie's path. ie) - .cookie(new NewCookie("last-visit", lastVisit)) + .cookie(new NewCookie("last-visit", lastVisit, "/", null, null, NewCookie.DEFAULT_MAX_AGE, false))

Anonymous  May 15, 2010 
Printed Page 260
~1/2 way down the page

The @HeaderParam("If-None-Match") String sent, is missing from the declaration of getCustomer(). The source code is correct.

Tim Barthel  Jan 26, 2012 
Printed Page 272
Last line before "The WAR Project"

I think HTTP error 500 means "Internal Server Error," not "Internal Service Error."

Jean-François Morin  Apr 13, 2011