Hi,
I am guessing that for the case when auth is enabled that a different
response is returned from the server to the client API. If you enable
client logging (see [1]) you might be better able to know what is gong
on.
Usually i would expect the client API to throw a UniformInterface
exception because 401 (Unauthorized) response would be returned.
Paul.
[1]
https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/client/filter/ClientFilter.html
On Jan 11, 2010, at 4:11 AM, cgswtsu78 wrote:
>
> Hello,
>
> Whenever I setup httpd basic authentication the below two resources
> fail and
> throw a ClientHandlerException (see details below) complaining about
> the
> media type not being found for ImageDetails. If I remove the httpd
> basic
> auth then both resource methods below work as expected. Anyone with
> any
> clues?
>
> Resources Class
> <code>
> @GET
> @Path("chart")
> @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
> public Response getTopSpamSenderChart(@QueryParam("w") String width,
> @QueryParam("h") String height, @QueryParam("chartType") String
> chartType, @QueryParam("fromDate") String fromDate,
> @QueryParam("toDate")
> String toDate) throws Exception{
>
> TopSpamSenderChart chart = topSpamSenderService.populateChart(width,
> height,
> chartType, fromDate, toDate);
> Client client = Client.create();
> WebResource webResource = client.resource(ChartUtils.getURL() +
> BASE_RESOURCE_LOCATION);
> ClientResponse response =
> webResource
> .path
> (TOP_SPAM_SENDER_CHART
> ).type(MediaType.APPLICATION_XML).post(ClientResponse.class,
> chart);
>
> return Response.ok(response.getEntity(ImageDetails.class)).build();
> }
>
> @GET
> @Path("chart")
> @Produces({"image/png"})
> public Response getTopSpamSenderChartAsImage(@QueryParam("w") String
> width,
> @QueryParam("h") String height, @QueryParam("chartType") String
> chartType,
> @QueryParam("fromDate") String fromDate, @QueryParam("toDate") String
> toDate) throws Exception{
>
> TopSpamSenderChart chart = topSpamSenderService.populateChart(width,
> height,
> chartType, fromDate, toDate);
>
> Client client = Client.create();
> WebResource webResource = client.resource(ChartUtils.getURL() +
> BASE_RESOURCE_LOCATION);
> ClientResponse response =
> webResource
> .path
> (TOP_SPAM_SENDER_CHART
> ).type(MediaType.APPLICATION_XML).post(ClientResponse.class,
> chart);
>
> return
> Response
> .ok
> (getChartAsImage(response.getEntity(ImageDetails.class))).build();
> }
>
> ImageDetails.java
> import java.awt.Image;
> import java.io.Serializable;
>
> import javax.xml.bind.annotation.XmlRootElement;
>
> @XmlRootElement(name="ImageDetails")
> public class ImageDetails implements Serializable{
>
> private static final long serialVersionUID = 326449095657073079L;
> private Image image;
>
> public Image getImage() {
> return image;
> }
>
> public void setImage(Image image) {
> this.image = image;
> }
>
>
>
> }
> </code>
>
> web.xml
> <!DOCTYPE web-app PUBLIC
> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd" >
>
> <web-app>
> <display-name>Archetype Created Web Application</display-name>
>
> <servlet>
> <servlet-name>Jersey Web Application</servlet-name>
>
> <servlet-
> class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-
> class>
> <init-param>
> <param-name>com.sun.jersey.config.property.packages</param-
> name>
> <param-value>com.proofpoint.reportsvcs.ws.impl</param-value>
> </init-param>
> <init-param>
>
> <param-name>com.sun.jersey.config.property.MediaTypeMappings</param-
> name>
> <param-value>json : application/json, xml : application/xml,
> stream
> : image/png</param-value>
> </init-param>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>Jersey Web Application</servlet-name>
> <url-pattern>/jersey/*</url-pattern>
> </servlet-mapping>
>
> </web-app>
>
>
>
>
> Jan 10, 2010 6:22:05 PM com.sun.jersey.spi.container.ContainerResponse
> mapMappableContainerException
> SEVERE: The RuntimeException could not be mapped to a response, re-
> throwing
> to the HTTP container
> com.sun.jersey.api.client.ClientHandlerException: A message body
> reader for
> Java type, class com.proofpoint.reportsvcs.entities.ImageDetails,
> and MIME
> media type, text/html;charset=iso-8859-1, was not found
> at
> com
> .sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:
> 526)
> at
> com
> .sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:
> 491)
> at
> com
> .proofpoint
> .reportsvcs
> .ws
> .impl
> .TopSpamSenderWSImpl.getTopSpamSenderChart(TopSpamSenderWSImpl.java:
> 74)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun
> .reflect
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun
> .reflect
> .DelegatingMethodAccessorImpl
> .invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> com
> .sun
> .jersey
> .server
> .impl.model.method.dispatch.AbstractResourceMethodDispatchProvider
> $
> ResponseOutInvoker
> ._dispatch(AbstractResourceMethodDispatchProvider.java:168)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .model
> .method
> .dispatch
> .ResourceJavaMethodDispatcher
> .dispatch(ResourceJavaMethodDispatcher.java:67)
> at
> com
> .sun
> .jersey
> .server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:259)
> at
> com
> .sun
> .jersey
> .server
> .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
> at
> com
> .sun
> .jersey
> .server
> .impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:83)
> at
> com
> .sun
> .jersey
> .server
> .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .uri
> .rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:71)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl._handleRequest(WebApplicationImpl.java:990)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
> at
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.service(WebComponent.java:
> 384)
> at
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:451)
> at
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:632)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> at
> org
> .apache
> .catalina
> .core
> .ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
> 290)
> at
> org
> .apache
> .catalina
> .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org
> .apache
> .catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
> 233)
> at
> org
> .apache
> .catalina.core.StandardContextValve.invoke(StandardContextValve.java:
> 191)
> at
> org
> .apache
> .catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> at
> org
> .apache
> .catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> at
> org
> .apache
> .catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
> 109)
> at
> org
> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
> 293)
> at
> org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
> at
> org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
> at
> org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
> at
> org
> .apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:
> 698)
> at
> org.apache.jk.common.ChannelSocket
> $SocketConnection.runIt(ChannelSocket.java:891)
> at
> org.apache.tomcat.util.threads.ThreadPool
> $ControlRunnable.run(ThreadPool.java:690)
> at java.lang.Thread.run(Thread.java:619)
> --
> View this message in context: http://n2.nabble.com/ClientHandlerException-When-Applying-HTTPD-Basis-Authentication-tp4283615p4283615.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>