title: unable to marshal type as an element because it is missing an @XmlRootElement annotation for auto generated classes
body: <p>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:</p>
  <blockquote>
  <p>unable to marshal type &quot;xyz&quot; as an element because it is missing an @XmlRootElement annotation</p>
  </blockquote>
  <p>Here is the code that I use to validate my autogenerated class object:</p>
  <pre><code>jc = JAXBContext.newInstance(obj.getClass());
  source = new JAXBSource(jc, obj);
  Schema schema = schemaInjector.getSchema();
  Validator validator = schema.newValidator();
  validator.validate(source);
  </code></pre>
  <p>Is there any other way I can solve this?</p>