You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2014/08/05 12:49:12 UTC

[jira] [Resolved] (CXF-5846) ClassCastException in org.apache.cxf.jaxrs.provider.BinaryDataProvider & SourceProvider

     [ https://issues.apache.org/jira/browse/CXF-5846?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin resolved CXF-5846.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 3.1.0
                   3.0.2
                   2.7.13
         Assignee: Sergey Beryozkin

Thanks for a patch, the only minor update I did was to do with logging an error message rather than reporting back to the client the signature details

> ClassCastException in  org.apache.cxf.jaxrs.provider.BinaryDataProvider & SourceProvider
> ----------------------------------------------------------------------------------------
>
>                 Key: CXF-5846
>                 URL: https://issues.apache.org/jira/browse/CXF-5846
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 3.0.0
>            Reporter: iris ding
>            Assignee: Sergey Beryozkin
>             Fix For: 2.7.13, 3.0.2, 3.1.0
>
>         Attachments: cxf-5846.patch
>
>
> 1.  Using Reader's Implementation BufferedReader: 
>     @POST
>     @Path("/subclasses/shouldfail")
>     public BufferedReader postReader(BufferedReader br) {
>         return br;
>     }
> Exception stack: 
>   Caused by: java.lang.ClassCastException: Cannot cast class java.io.InputStreamReader to class java.io.BufferedReader
> 	at java.lang.Class.cast(Class.java:1730)
> 	at org.apache.cxf.jaxrs.provider.BinaryDataProvider.readFrom(BinaryDataProvider.java:77)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1311)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1262)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:801)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:764)
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212)
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:76)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
> 	... 19 more
> 2. Using ByteArrayInputStream:
> @POST
>     @Path("/subclasses/shouldfail")
>     public ByteArrayInputStream postInputStream(ByteArrayInputStream is) {
>         return is;
>     }
> Exception stack:
> Caused by: java.lang.ClassCastException: Cannot cast class org.apache.cxf.transport.http.AbstractHTTPDestination$1 to class java.io.ByteArrayInputStream
> 	at java.lang.Class.cast(Class.java:1730)
> 	at org.apache.cxf.jaxrs.provider.BinaryDataProvider.readFrom(BinaryDataProvider.java:74)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1311)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1262)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:801)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:764)
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212)
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:76)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
> 	... 19 more
> 3.  Using Source's implmentation class: 
> public static class UnsupportedSourceSubclass implements Source {
>         public String getSystemId() {
>             return null;
>         }
>         public void setSystemId(String systemId) {
>         }
>     }
>     @POST
>     @Path("/subclasses/shouldfail")
>     public UnsupportedSourceSubclass postReader(UnsupportedSourceSubclass saxSource) {
>         return saxSource;
>     }
> Exception stack:
> Caused by: java.lang.ClassCastException: Cannot cast class javax.xml.transform.stream.StreamSource to class com.test.jaxrs.fat.standard.SourceResource$UnsupportedSourceSubclass
> 	at java.lang.Class.cast(Class.java:1730)
> 	at org.apache.cxf.jaxrs.provider.SourceProvider.readFrom(SourceProvider.java:115)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1311)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1262)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:801)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:764)
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212)
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:76)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
> 	... 19 more



--
This message was sent by Atlassian JIRA
(v6.2#6252)