unable to marshal type as an element because it is missing an @XmlRootElement annotation for auto generated classes
I need to validate Class object against my schema in which I have provided regular expression to validate fields for auto generated JAXB classes. When I try to validate my class object I get below error:
unable to marshal type "xyz" as an element because it is missing an @XmlRootElement annotation
Here is the code that I use to validate my autogenerated class object:
jc = JAXBContext.newInstance(obj.getClass());
source = new JAXBSource(jc, obj);
Schema schema = schemaInjector.getSchema();
Validator validator = schema.newValidator();
validator.validate(source);
Is there any other way I can solve this?