[ 
https://issues.apache.org/jira/browse/CXF-4075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13212020#comment-13212020
 ] 

sonali majumdar commented on CXF-4075:
--------------------------------------

I am facing a similar issue using Jackson1.9.3. Client API throws the error -

Caused by: org.apache.cxf.jaxrs.client.ClientWebApplicationException: .No 
message body reader has been found for class : interface java.util.List, 
ContentType : text/html;charset=utf-8.
        at 
org.apache.cxf.jaxrs.client.AbstractClient.reportMessageHandlerProblem(AbstractClient.java:589)
        at 
org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:443)
        at 
org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:520)
        at 
org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:480)
        at 
org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:188)
        at $Proxy344.getBooksForSubscriber(Unknown Source)

Here are the other relevant files - 

1) Client Spring configuration file 
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:jaxrs="http://cxf.apache.org/jaxrs";
    xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd";>

<jaxrs:client id = "BookService" address = 
"http://localhost:8080/restful/services/lib";
                  serviceClass="com.sample.library.BooksMgmtService">
        <jaxrs:providers>
            <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
        </jaxrs:providers>
    </jaxrs:client>
</beans>



2) Server Spring configuration file 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:jaxrs="http://cxf.apache.org/jaxrs";
    xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd";>

 <jaxrs:server id="restBooksRegistry"
                    address="/lib"
                    staticSubresourceResolution="true">
        <jaxrs:serviceBeans>
          <ref bean="bookRegistry"/>
        </jaxrs:serviceBeans>

        <jaxrs:providers>
            <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
            <bean class="com.sample.library.exp.BookNotFoundExceptionMapper" />
        </jaxrs:providers>
      </jaxrs:server>

    <bean id="bookRegistry" class="com.sample.library.impl.BookMgmtServiceImpl">

    </bean>
</beans>


3) Rest interface that is exposed

@Path("/booksRegistry/")
public interface BookMgmtService {

    @POST
    @Path("/getByCriteria")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    List<Books> getBooksForSubscriber(BookSubscriber subscriberId);
}

I am on Linux. It works perfectly on Windows .. But does that make any 
difference ? I tried using the custom jaxbProvider as you suggested but it does 
not work ..  

Do you know what the issue is ? 

Thanks,

                
> The JAX-RS : Client API Unable to Handle Response Content Type "text/plain". 
> Throws ClientWebApplicationException When Client Service Method is Invoked
> -------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-4075
>                 URL: https://issues.apache.org/jira/browse/CXF-4075
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.5
>         Environment: OS: Windows XP
> JDK Version: 6
>            Reporter: Nathan Gulley
>            Priority: Critical
>             Fix For: Invalid
>
>
> The JAX-RS : Client API is unable to handle response content type 
> "text/plain". The proxy client throws a ClientWebApplicationException
> when the service call is made:
> org.apache.cxf.jaxrs.client.ClientWebApplicationException: .No message body 
> reader has been found for class : class 
> com.sears.forgotpassword.ForgotPassword, ContentType : text/plain.
>       at 
> org.apache.cxf.jaxrs.client.AbstractClient.reportMessageHandlerProblem(AbstractClient.java:593)
>       at 
> org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:445)
>       at 
> org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:527)
>       at 
> org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:487)
>       at 
> org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:188)
>       at $Proxy16.forgotPassword(Unknown Source)
>       at 
> com.sears.mobilegateway.test.SHCAPIProfileServiceTest.testForgotPassword(SHCAPIProfileServiceTest.java:231)
> WEB SERVICE URL: 
> http://webservices.sears.com/shcapi/ForgotPassword?store=Sears&appID=MOB_IPH_SEARS_2GO&authID=xxxxxxxxxx&langId=-1&catalogId=12605&email=ngul23as19...@yahoo.com
> RESPONSE CONTENT TYPE: text/plain
> RESPONSE CONTENT:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?> 
>        <ForgotPassword>
>            <StatusData>
>                <ResponseCode>0</ResponseCode>
>                <RespMessage><![CDATA[Action is successful.Please check your 
> email account for instructions on how to choose your new 
> password.]]></RespMessage>   
>            </StatusData> 
>            <ServiceHeaders>        
>                <Store>        10153        </Store>        
>                <LangId>        -1        </LangId>        
>                <clientSessionKey>        3uDXyoc2vtZi35gk3UVdyOC        
> </clientSessionKey>
>            </ServiceHeaders>
>        </ForgotPassword>
> Here are the detailed steps you need to follow in order to reproduce the bug:
> 1.  Define a REST client service class that points to a RESTful web service 
> that returns content type "text/plain"
> CLASS:  import javax.ws.rs.GET;
>         import javax.ws.rs.POST;
>         import javax.ws.rs.Path;
>         import javax.ws.rs.QueryParam;
>         import com.sears.forgotpassword.ForgotPassword;        
>         public interface SHCAPIProfileService {
>           @Path("/shcapi/ForgotPassword") @GET 
>         public ForgotPassword forgotPassword(@QueryParam("email") String 
> email,
>                                              @QueryParam("appID") String 
> appID, 
>                                              @QueryParam("authID") String 
> authID, 
>                                              @QueryParam("store") String 
> store,
>                                              @QueryParam("catalogId") String 
> catalogId,
>                                              @QueryParam("langId") String 
> langId);
>         }
> 2. Add the service class to your Spring configuration file as a CXF JAX-RS 
> client bean. Configure the bean to accept content type  
>    "text/plain":
> <jaxrs:client id="shcapiProfileService" 
> address="https://webservices.sears.com:"; 
> serviceClass="com.sears.mobilegateway.service.SHCAPIProfileService" 
> inheritHeaders="true">
>         <jaxrs:headers>
>           <entry key="Accept" value="text/plain"/>
>           <entry key="Accept" value="text/xml"/>                  
>       </jaxrs:headers>
> </jaxrs:client>
> 3. Use a Spring ApplicationContext to reference an instance of the client 
> service bean in your code:
>  
>    ApplicationContext applicationContext = new 
> ClassPathXmlApplicationContext("spring-business-context.xml"); 
>    SHCAPIProfileService shcapiProfileService = 
> (SHCAPIProfileService)applicationContext.getBean("shcapiProfileService");
> 4. Call the "forgotPassword" service method on the service class:
>    ForgotPassword responseObj = shcapiProfileService.forgotPassword(LOGIN_ID, 
> APP_ID, AUTH_ID, STORE, CATALOG_ID, LANG_ID);   
>       
> 5. The following ClientWebApplicationException is thrown when JAXB tries to 
> unmarshall the response content into the "ForgotPassword" Java object:
> org.apache.cxf.jaxrs.client.ClientWebApplicationException: .No message body 
> reader has been found for class : class 
> com.sears.forgotpassword.ForgotPassword, ContentType : text/plain.
>       at 
> org.apache.cxf.jaxrs.client.AbstractClient.reportMessageHandlerProblem(AbstractClient.java:593)
>       at 
> org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:445)
>       at 
> org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:527)
>       at 
> org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:487)
>       at 
> org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:188)
>       at $Proxy16.forgotPassword(Unknown Source)
>       at 
> com.sears.mobilegateway.test.SHCAPIProfileServiceTest.testForgotPassword(SHCAPIProfileServiceTest.java:231)
>       
> NOTE: This exception should not occur since we configured the service class 
> to accept content type "text/plain" in step 2.
>       I tried work arounds such as customizing the proxy by running the 
> following code before making the client service call:
>       WebClient.client(shcapiProfileService).accept("text/plain");
>       However these had no effect. The same error occurs.
>     

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to