Errata

RESTful Java with JAX-RS 2.0

Errata for RESTful Java with JAX-RS 2.0, Second Edition

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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
PDF
Page Page 225
United States

" it doesn�t define one for simple protocols like . "

is an incomplete sentence.

Note from the Author or Editor:
Last paragraph of PDF p. 225 there is an incomplete sentence.

..... it doesn't doesn’t define one for simple protocols like.

Expand this sentence to

it doesn’t define one for simple protocols like Basic or Digest authentication.

Arun Gupta  Dec 03, 2013  Aug 14, 2015
Chapter 13. Asynchronous JAX-RS
Server Asynchronous Response Processing > Exception Handling

The sample code takes "AsyncResponse response" as an argument, then inside the Thread.run() method it creates "Response response" (same name). Therefore response.resume(response); will generate a compiler error. It doesn't find a method "resume" for Response.


public void submit(final Order order,
final @Suspended AsyncResponse response) {
new Thread() {
public void run() {
...
Response response = Response.ok(confirmation,
MediaType.APPLICATION_XML_TYPE)
.build();
response.resume(response);
}
}.start();
}


We should rename the Response object inside Thread.run to something else to avoid hiding the AsyncResponse object.

Something like:

Response r = Response.ok(confirmation,
MediaType.APPLICATION_XML_TYPE)
.build();

response.resume( r );

Note from the Author or Editor:
p. 194 of PDF Change code block to:

Response res= Response.ok(confirmation,
MediaType.APPLICATION_XML_TYPE)
.build();
res.resume(response);

Hani Ezzadeen  Dec 08, 2013  Aug 14, 2015
Chapter 13. Asynchronous JAX-RS
Server Asynchronous Response Processing > Timeouts

The following code generates a compiler error

response.setTimeoutHandler(
new TimeoutHandler {
void handleTimeout(AsyncResponse response) {
response.resume(Response.serverError().build());
}
}
);

There is a missing "()" for the TimeoutHandler constructor. Also, the handleTimeout method must be declared "public".

The code without the missing parts would be:

response.setTimeoutHandler(
new TimeoutHandler() {
public void handleTimeout(AsyncResponse response) {
response.resume(Response.serverError().build());
}
}
);

Note from the Author or Editor:
p. 196 of PDF, the last code block should be

response.setTimeoutHandler(
new TimeoutHandler() {
public void handleTimeout(AsyncResponse response) {
response.resume(Response.serverError().build());
}
}
);

Hani Ezzadeen  Dec 08, 2013  Aug 14, 2015
United States

Chapter 17, "Example Requirements and Structure" states JDK 6.0 or later is required. When I used the examples in Rest Easy3.0.7 and tried to build ex03_1, I found that JDK 7 is actually required in order for the build to complete successfully.

Note from the Author or Editor:
p. 251 of print. Change

"JDK 6.0 or later" to "JDK 7.0 or later"

Greg Totsline  May 04, 2014  Aug 14, 2015
Mobi
Page loc 776
First sentence

The word "is" is missing from "While it usually possible …"

Note from the Author or Editor:
p. 22 of PDF. 2nd paragraph is missing an "is"

White it usually possible

should change to

Whilte it is usually possible

Vincent van ’t Zand  May 14, 2015  Aug 14, 2015
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 = client.target("http://commerce.com/customers/123")
.accept("application/json")
.get(Customer.class);

List<Customer> customer = client.target("http://commerce.com/customers")
.accept("application/xml")
.get(new GenericType<List<Customer>>() {});

Note from the Author or Editor:
P. 117 of PDF last code block add .request() before .accept()

.request().accept("application/json")

P. 118 of PDF, first code block, add .request() before .accept()

.request().accept("application/xml")

Hani Ezzadeen  Dec 02, 2013  Aug 14, 2015
PDF
Page 47
First code for the HTTP request

PUT /orders/233 HTTP/1.1
Content-Type: application/xml
<product id="111">
<name>iPhone</name>
<cost>$149.99</cost>
</product>

If this request is for changing the product´s price, why is the resource path "/orders/233"? I would expect "/products" instead.

Thanks.

Note from the Author or Editor:
In the code block in the middle of p. 23 of the PDF, change

PUT /orders/233 HTTP/1.1

to

PUT /products/111 HTTP/1.1

Frederico Pereira  Apr 27, 2015  Aug 14, 2015
Printed
Page 130
last paragraph

Missing space between "deal" and "with".

Anonymous  Jun 06, 2014  Aug 14, 2015
PDF
Page 172
at the end of the method filter of CacheControlFilter

replace req.getHeaders
by res.getHeaders

Note from the Author or Editor:
In code block on page 172, replace

req.getHeaders

with

res.getHeaders

Richard Grin  Sep 02, 2014  Aug 14, 2015
Printed
Page 210
Source Code

Dear author,

In the code example that shows injecting ServletContext in Application class to initialize resources with servlet context parameters, you've injected ServletContext well,however in getSingleton() method, you're also initializing a new InitialContext() to get the values for context parameters. It appears these values should be pulled from ServletContext instance.

Note from the Author or Editor:
p. 210 of printed. change this code

try {
InitiialContext ctx = new InitialContext();
Integer size = (Integer)ctx.getInitParameter(...);

Changes to make/

1. Remove the InitialContext ctx = new IntiailContext() line entirely
2. The next line changes to

Integer size = (Integer)servletContext.getInitParameter(

Anand Prakash  Feb 28, 2014  Aug 14, 2015
PDF
Page 225
United States

It says "For example, the RESTEasy framework provides a ContainerRequestFilter" but it is a ClientRequestFilter.

Note from the Author or Editor:
p. 225 of PDF. Change last sentence of last paragraph

From:

the RESTEasy framework provides a ContainerRequestFilter

to:

The RESTEasy framework ClientRequestFilter

Christopher M. Judd  Jul 22, 2014  Aug 14, 2015
PDF
Page 225
United States

The code example at the bottom of the page shows calling the newClient method on client. That method does not exist. Instead it should be ClientBuilder.newClient(). See http://docs.oracle.com/javaee/7/api/javax/ws/rs/client/ClientBuilder.html#newClient().

Note from the Author or Editor:
P. 225 of PDF code fragment near end of page

change:

Client client = Client.newClient();

to

Client client = ClientBuilder.newClient();

Christopher M. Judd  Jul 22, 2014  Aug 14, 2015
Printed
Page 227
last sentenct of first paragraph

"separate" is misspelled

Note from the Author or Editor:
p. 227 of print, last sentence first paragraph

seperate change to correct spelling of separate

Anonymous  Jun 06, 2014  Aug 14, 2015
Mobi
Page 10285
United States

3. Perform the build by typing maven install.
should be
3. Perform the build by typing mvn install

Note from the Author or Editor:
Throughout the whole book replace

Perform the build and run the example by typing maven install.

with

Perform the build and run the example by typing mvn install.

Mark Glass  Nov 29, 2013  Aug 14, 2015