title: CXF JSON Schema Validation
body: <p>I am writing RESTFul webservices which support both XML and JSON format. I need to add schema validation in the webservices. My beans are auto generated using JAX-B. As suggested at CXF's site at <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS+Data+Bindings#JAX-RSDataBindings-Schemavalidation" rel="nofollow">Schema validation</a>, I am using <code>org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider</code> as JSON provider and <code>org.apache.cxf.jaxrs.provider.JAXBElementProvider</code> as JAX-B provider. The request and response is working fine but now I want to add schema validation.</p>
  
  <p>The sample code at above CXF link is not working for me for JSON schema validation (its working for XML schema validation). They shown it for <code>org.apache.cxf.jaxrs.provider.json.JSONProvider</code> (under 'Schema Validation' section) which doesn't work for me as my beans are JAX-B generated, so I am using <code>JacksonJaxbJsonProvider</code>.</p>
  
  <p>Is there any solution for this problem? Could somebody please suggest some approach that I can try?</p>
  
  <p>Below is the XML configuration:</p>
  
  <p>
          
      </p>
  
  <pre><code>&lt;bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider"/&gt;      
  
  &lt;bean id="schemaHolder" class="org.apache.cxf.jaxrs.utils.schemas.SchemaHandler"&gt;
      &lt;property name="schemas" ref="theSchemas"/&gt;
  &lt;/bean&gt;
  
  &lt;util:list id="theSchemas"&gt;
    &lt;value&gt;classpath:/WEB-INF/classes/po.xsd&lt;/value&gt;
  &lt;/util:list&gt;
  
  &lt;!-- Person REST Service Configurations --&gt;
  &lt;bean id="personRESTServiceImpl" class="com.abc.webservices.service.rest.PersonRESTService" /&gt;
  &lt;jaxrs:server id="personRESTService" address="/person-rest-service"&gt;
      &lt;jaxrs:serviceBeans&gt;
          &lt;ref bean="personRESTServiceImpl" /&gt;
      &lt;/jaxrs:serviceBeans&gt;
      &lt;jaxrs:providers&gt;
          &lt;ref bean="jaxbProvider" /&gt;
          &lt;ref bean='jsonProvider' /&gt;
      &lt;/jaxrs:providers&gt;
  &lt;/jaxrs:server&gt;
  </code></pre>