After digging into Resteasy sources it seems to me that target class has to be annotated with XmlType in order for RE to start looking for the ObjectFactory:
public abstract class AbstractJAXBContextFinder implements JAXBContextFinder
{
protected static final String OBJECT_FACTORY_NAME = ".ObjectFactory";
public static Class<?> findDefaultObjectFactoryClass(Class<?> type)
{
XmlType typeAnnotation = type.getAnnotation(XmlType.class);
if (typeAnnotation == null) return null;
if (!typeAnnotation.factoryClass().equals(XmlType.DEFAULT.class)) return null;
StringBuilder b = new StringBuilder(getPackageName(type));
b.append(OBJECT_FACTORY_NAME);
Class<?> factoryClass = null;
try
{
factoryClass = Thread.currentThread().getContextClassLoader().loadClass(b.toString());
}
catch (ClassNotFoundException e)
{
return null;
}
if (factoryClass.isAnnotationPresent(XmlRegistry.class)) return factoryClass;
return null;
}
}
I added @XmlType annotation on the class, and RestEasy readEntity() call is now unmarshalling properly. I still have to run full tests, but right now it seems to me like this works.
Seems like a bug in Resteasy: object factory should also be loaded for @XmlRootElement annotated classes.