Wednesday, 16 May 2012

JAXB: Marshal exception while marshalling generics, class nor any of its classes known to this context

If you have a class as ServiceResult<T> with a generic parameter and you get exception as "class my.examples.dto.ResultDto nor any of its classes known to this context" while marshalling although you have ResultDto in Jaxb context, try @XmlSeeAlso as below

@XmlRootElement
@XmlSeeAlso(ResultDto.class, ResultDtoAnother.class)
public class ServiceResult<T> {
public T result;
}

This resolves the issue temporarily until we have a cleaner solution from JaxB

No comments:

Post a Comment