Hi Sergey,

I think I found the bug: in the method JAXBElementProvider.writeTo it's
necessary to add a call to AbstractJAXBProvider.getActualType(Class<?> type,
Type genericType, Annotation[] anns) before calling marshalCollection
method.

I created a new class that extends JAXBElementProvider and orverwrites
writeTo method. I've just added the line below to solve the problem.
actualClass = getActualType(actualClass, genericType, anns);


See the code below:


public class MyJAXBElementProvider extends JAXBElementProvider{
        
        public void writeTo(Object obj, Class<?> cls, Type genericType,
Annotation[] anns,  
                MediaType m, MultivaluedMap<String, Object> headers, 
OutputStream
os) 
                throws IOException {
                try {
                    Object actualObject = checkAdapter(obj, cls, anns, true);
                    Class<?> actualClass = obj != actualObject ?
actualObject.getClass() : cls;
                    String encoding = HttpUtils.getSetEncoding(m, headers, 
null);
                    if 
(InjectionUtils.isSupportedCollectionOrArray(actualClass)) {                    
 
                        actualClass = InjectionUtils.getActualType(genericType);
                        
                        /*  added ***********************************/ 
                            actualClass = getActualType(actualClass, 
genericType, anns);
                                /* ****************************************/    
                                               
                        
                        marshalCollection(cls, actualObject, actualClass,
genericType, encoding, os, m);
                    } else {
                        marshal(actualObject, actualClass, genericType, 
encoding,
os, m);
                    }
                } catch (JAXBException e) {
                    handleJAXBException(e);
                }  catch (WebApplicationException e) {
                    throw e;
                } catch (Exception e) {
                    throw new WebApplicationException(e);        
                }
            }   
}


I think the same change is necessary for JSONProvider.

Regards,
Elias
-- 
View this message in context: 
http://cxf.547215.n5.nabble.com/JAX-RS-service-w-interface-result-type-XmlJavaTypeAdapter-tp564352p1861836.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to