Paul,
Thanks for your help. My getSize() was returning 0. I see why it worked
in 0.8 and not 0.9.
-Reece
>>> Paul Sandoz <Paul.Sandoz_at_Sun.COM> 8/22/2008 3:00:03 PM >>>
On Aug 22, 2008, at 10:50 PM, Reece Garrett wrote:
> The problem is in line 132 of
> com.sun.jersey.spi.container.ContainerResponse:
>
> Jersey version 0.8 —-> o =
responseWriter.writeStatusAndHeaders(-1,
> ContainerResponse.this);
> Jersey version 0.9 —-> o =
responseWriter.writeStatusAndHeaders(size,
> ContainerResponse.this);
>
> I reverted that line back to what it was in 0.8 and it works.
>
The "size" is set from what is returned by the getSize method of the
selected message body writer, see line 232 of Jersey version 0.9
ContainerResponse (see below). So if a writer does not know the size
of what is being written then the method should return -1.
Paul.
final MessageBodyWriter p = bodyContext.getMessageBodyWriter(
entity.getClass(), entityType,
null, contentType);
// If there is no message body writer return a Not
Acceptable response
if (p == null) {
LOGGER.severe("A message body reader for Java type, " +
entity.getClass() +
", and MIME media type, " + contentType + ", was
not found");
if (request.getMethod().equals("HEAD")) {
responseWriter.writeStatusAndHeaders(-1, this);
return;
} else
throw new WebApplicationException
(Responses.notAcceptable().build());
}
final long size = p.getSize(entity); <------ get
the size from the writer
if (request.getMethod().equals("HEAD")) {
if (size != -1)
getHttpHeaders().putSingle("Content-Length",
Long.toString(size));
} else {
p.writeTo(entity, entity.getClass(), entityType, null,
contentType, getHttpHeaders(),
new CommittingOutputStream(size));
}
> -Reece
>
>>>> "Reece Garrett" <RGARRET_at_co.pierce.wa.us> 8/22/2008 1:21 PM >>>
> Hello,
>
> I am using Jetty web server and just upgraded to jersey 0.9. I am
> using
> my own json entity provider which was working with jersey 0.8 but
now
> that I've upgraded I get no response body. I get the right response
> code
> but not my entity representation. I've debugged and verified that
> when I
> call outputStream.write(representation.getBytes()); that the
> representation is correct but it just doesn't make it into the
> response.
> I am using the spring-servlet. Any ideas?
>
> -Reece
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
For additional commands, e-mail: users-help_at_jersey.dev.java.net