You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Shaun Elliott (JIRA)" <ji...@apache.org> on 2011/06/24 14:39:47 UTC

[jira] [Created] (CXF-3617) Automatic Type Converters for Restful Clients

Automatic Type Converters for Restful Clients
---------------------------------------------

                 Key: CXF-3617
                 URL: https://issues.apache.org/jira/browse/CXF-3617
             Project: CXF
          Issue Type: Improvement
          Components: JAX-RS
            Reporter: Shaun Elliott


Given the following interface:
{code}
@POST
@Path( "execute" )
@Produces( "application/json" )
MyObject execute( MyObject myObject );
{code}

One must provide MessageBodyReader\Writer or face the following exception:
{code}
Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
    at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
    at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
    at $Proxy13.execute(Unknown Source)
    at com.company.JaxTestClient.main(JaxTestClient.java:26)
{code}

Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.

See here for more information: 
http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CXF-3617) Automatic Type Converters for Restful Clients

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069296#comment-13069296 ] 

Sergey Beryozkin commented on CXF-3617:
---------------------------------------

No - you just need to register a provider which is capable of mapping all the objects you are dealing with to/from format which needs to be supported.


> Automatic Type Converters for Restful Clients
> ---------------------------------------------
>
>                 Key: CXF-3617
>                 URL: https://issues.apache.org/jira/browse/CXF-3617
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Shaun Elliott
>
> Given the following interface:
> {code}
> @POST
> @Path( "execute" )
> @Produces( "application/json" )
> MyObject execute( MyObject myObject );
> {code}
> One must provide MessageBodyReader\Writer or face the following exception:
> {code}
> Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
>     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy13.execute(Unknown Source)
>     at com.company.JaxTestClient.main(JaxTestClient.java:26)
> {code}
> Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.
> See here for more information: 
> http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CXF-3617) Automatic Type Converters for Restful Clients

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069519#comment-13069519 ] 

Sergey Beryozkin commented on CXF-3617:
---------------------------------------

No. CXF can not magically support all the media types/formats/mappings - just register a custom provider.
I'm going to close this as won't fix...

> Automatic Type Converters for Restful Clients
> ---------------------------------------------
>
>                 Key: CXF-3617
>                 URL: https://issues.apache.org/jira/browse/CXF-3617
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Shaun Elliott
>
> Given the following interface:
> {code}
> @POST
> @Path( "execute" )
> @Produces( "application/json" )
> MyObject execute( MyObject myObject );
> {code}
> One must provide MessageBodyReader\Writer or face the following exception:
> {code}
> Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
>     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy13.execute(Unknown Source)
>     at com.company.JaxTestClient.main(JaxTestClient.java:26)
> {code}
> Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.
> See here for more information: 
> http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CXF-3617) Automatic Type Converters for Restful Clients

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068919#comment-13068919 ] 

Sergey Beryozkin commented on CXF-3617:
---------------------------------------

Sorry - saw this issue but got sidetracked, 

You can register Jackson provider or xStream one (as suggested at StackOverflow page you linked to) when creating WebClient.
Do you agree this is a non-fix issue, but mainly a configuration issue ?

> Automatic Type Converters for Restful Clients
> ---------------------------------------------
>
>                 Key: CXF-3617
>                 URL: https://issues.apache.org/jira/browse/CXF-3617
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Shaun Elliott
>
> Given the following interface:
> {code}
> @POST
> @Path( "execute" )
> @Produces( "application/json" )
> MyObject execute( MyObject myObject );
> {code}
> One must provide MessageBodyReader\Writer or face the following exception:
> {code}
> Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
>     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy13.execute(Unknown Source)
>     at com.company.JaxTestClient.main(JaxTestClient.java:26)
> {code}
> Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.
> See here for more information: 
> http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CXF-3617) Automatic Type Converters for Restful Clients

Posted by "Shaun Elliott (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069622#comment-13069622 ] 

Shaun Elliott commented on CXF-3617:
------------------------------------

Why not? As I've stated before, the Restlet library does it very elegantly therefore it is possible.

> Automatic Type Converters for Restful Clients
> ---------------------------------------------
>
>                 Key: CXF-3617
>                 URL: https://issues.apache.org/jira/browse/CXF-3617
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Shaun Elliott
>            Assignee: Sergey Beryozkin
>
> Given the following interface:
> {code}
> @POST
> @Path( "execute" )
> @Produces( "application/json" )
> MyObject execute( MyObject myObject );
> {code}
> One must provide MessageBodyReader\Writer or face the following exception:
> {code}
> Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
>     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy13.execute(Unknown Source)
>     at com.company.JaxTestClient.main(JaxTestClient.java:26)
> {code}
> Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.
> See here for more information: 
> http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CXF-3617) Automatic Type Converters for Restful Clients

Posted by "Shaun Elliott (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069104#comment-13069104 ] 

Shaun Elliott commented on CXF-3617:
------------------------------------

Right, I've looked over the JAXB default binding and that works well if your objects are already annotated as such. However, if they are not what then? You must register readers\writers for all other objects? What about the solution provide by the stackoverflow post? Could something like that not be provided in the library? I mean, ultimately from an end user perspective I don't care too much which provider is used: XStream, Jackson, etc - any would be fine. I just want it to handle object serialization over the wire seamlessly. I hope this makes sense :)

> Automatic Type Converters for Restful Clients
> ---------------------------------------------
>
>                 Key: CXF-3617
>                 URL: https://issues.apache.org/jira/browse/CXF-3617
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Shaun Elliott
>
> Given the following interface:
> {code}
> @POST
> @Path( "execute" )
> @Produces( "application/json" )
> MyObject execute( MyObject myObject );
> {code}
> One must provide MessageBodyReader\Writer or face the following exception:
> {code}
> Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
>     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy13.execute(Unknown Source)
>     at com.company.JaxTestClient.main(JaxTestClient.java:26)
> {code}
> Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.
> See here for more information: 
> http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CXF-3617) Automatic Type Converters for Restful Clients

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069102#comment-13069102 ] 

Sergey Beryozkin commented on CXF-3617:
---------------------------------------

> No, I think a better solution would be automatic registration. This is how the Restlet library does it. You don't have to worry about mappings. 

Well, we do ship a default JSONProvider which assumes objects are JAXB beans - those will be automatically mapped. On top of it we can customize a lot JSONProvider works with data. Thus we can't drop it and replace with Jackson or XMLStream provider.  
We can also application/x+bar medium type and MyObject - would you expect it automatically mapped as well ?

The point I'm making is that we ship a default JSONProvider. And registering custom or existing 3rd party providers is very easy. Even if CXF did ship say XStream provider then you;d still need to register it explicitly for it to be preferred to the default JSONProvider - but I don't think we can afford shipping multiple JSON providers


> Automatic Type Converters for Restful Clients
> ---------------------------------------------
>
>                 Key: CXF-3617
>                 URL: https://issues.apache.org/jira/browse/CXF-3617
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Shaun Elliott
>
> Given the following interface:
> {code}
> @POST
> @Path( "execute" )
> @Produces( "application/json" )
> MyObject execute( MyObject myObject );
> {code}
> One must provide MessageBodyReader\Writer or face the following exception:
> {code}
> Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
>     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy13.execute(Unknown Source)
>     at com.company.JaxTestClient.main(JaxTestClient.java:26)
> {code}
> Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.
> See here for more information: 
> http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CXF-3617) Automatic Type Converters for Restful Clients

Posted by "Shaun Elliott (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069319#comment-13069319 ] 

Shaun Elliott commented on CXF-3617:
------------------------------------

Couldn't this be provided? My guess is that other libraries most likely use reflection to do it by default.

> Automatic Type Converters for Restful Clients
> ---------------------------------------------
>
>                 Key: CXF-3617
>                 URL: https://issues.apache.org/jira/browse/CXF-3617
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Shaun Elliott
>
> Given the following interface:
> {code}
> @POST
> @Path( "execute" )
> @Produces( "application/json" )
> MyObject execute( MyObject myObject );
> {code}
> One must provide MessageBodyReader\Writer or face the following exception:
> {code}
> Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
>     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy13.execute(Unknown Source)
>     at com.company.JaxTestClient.main(JaxTestClient.java:26)
> {code}
> Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.
> See here for more information: 
> http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CXF-3617) Automatic Type Converters for Restful Clients

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin resolved CXF-3617.
-----------------------------------

    Resolution: Not A Problem
      Assignee: Sergey Beryozkin

doing something like WebClient.create(address, 
Collections.singleton(new JacksonProvider())) will 'fix' it.



> Automatic Type Converters for Restful Clients
> ---------------------------------------------
>
>                 Key: CXF-3617
>                 URL: https://issues.apache.org/jira/browse/CXF-3617
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Shaun Elliott
>            Assignee: Sergey Beryozkin
>
> Given the following interface:
> {code}
> @POST
> @Path( "execute" )
> @Produces( "application/json" )
> MyObject execute( MyObject myObject );
> {code}
> One must provide MessageBodyReader\Writer or face the following exception:
> {code}
> Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
>     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy13.execute(Unknown Source)
>     at com.company.JaxTestClient.main(JaxTestClient.java:26)
> {code}
> Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.
> See here for more information: 
> http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CXF-3617) Automatic Type Converters for Restful Clients

Posted by "Shaun Elliott (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069088#comment-13069088 ] 

Shaun Elliott commented on CXF-3617:
------------------------------------

No, I think a better solution would be automatic registration. This is how the Restlet library does it. You don't have to worry about mappings. 

Furthermore, I would think a generic MessageBody[Reader|Writer] like the accepted answer would be part of the library already. I don't understand why it is not (though, admittedly, I am ignorant to some of the workings of restful web service clients).

> Automatic Type Converters for Restful Clients
> ---------------------------------------------
>
>                 Key: CXF-3617
>                 URL: https://issues.apache.org/jira/browse/CXF-3617
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Shaun Elliott
>
> Given the following interface:
> {code}
> @POST
> @Path( "execute" )
> @Produces( "application/json" )
> MyObject execute( MyObject myObject );
> {code}
> One must provide MessageBodyReader\Writer or face the following exception:
> {code}
> Exception in thread "main" org.apache.cxf.interceptor.Fault: .No message body writer found for class : class com.company.datatype.normal.MyObject.
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:523)
>     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:438)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy13.execute(Unknown Source)
>     at com.company.JaxTestClient.main(JaxTestClient.java:26)
> {code}
> Other competing libraries (such as Restlet) support automatic type mapping out of the box via XStream and Jackson. Given CXF's compliance to JAX-RS it would be helpful if this boilerplate type code were given out of the box too.
> See here for more information: 
> http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-re

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira