The Jaxb2XmlEncoder seem to not support JAXBElement type while Marshaller can encode it. The use case for it is when one have the XML binding class that one don't own and cannot add @XmlRootElement.

Comment From: bclozel

Can you share a sample application (ideally one created with start.spring.io) that demonstrates the problem please?

Comment From: nstdio

Sure you can find the failing test case in gh-30552.zip

Comment From: nstdio

I wonder why would Jaxb2XmlEncoder support classes annotated with @XmlRootElement or @XmlType, when underlying marshaller is unable to encode classes annotated only @XmlType. Maybe there is something I'm missing?