title: JAXB - SAXParseException Cannot find the declaration of element
body: <p>I have a problem trying to validate an object with a given xsd.
  The classes has been generated from the xsd.</p>
  
  <pre><code>SchemaFactory factory = SchemaFactory
                  .newInstance("http://www.w3.org/2001/XMLSchema");
  Schema schema = factory.newSchema(getClass().getResource("/xsd/test.xsd"));
  JAXBContext context = JAXBContext.newInstance(aClass);
  Unmarshaller u = context.createUnmarshaller();
  u.setSchema(schema);
  Object anObject = u.unmarshal(new StreamSource(new StringReader(
                  MESSAGE)), aClass);
  </code></pre>
  
  <p>Here is the exception message</p>
  
  <p>[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ACCESREFUSE'.]</p>
  
  <p>Here is the XSD :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:include schemaLocation="./include/CJCommon.xsd"/&gt;
   &lt;xs:element name="ACCESREFUSE"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence maxOccurs="1" minOccurs="1"&gt;
      &lt;!-- Entete --&gt;
      &lt;xs:element maxOccurs="1" minOccurs="1" ref="IDOper"/&gt;
      &lt;xs:element maxOccurs="1" minOccurs="1" ref="DateEvt"/&gt;
      &lt;xs:element maxOccurs="1" minOccurs="1" ref="IDEvt"/&gt;
      &lt;xs:element maxOccurs="1" minOccurs="1" ref="IDJoueur"/&gt;
      &lt;xs:element maxOccurs="1" minOccurs="1" ref="HashJoueur"/&gt;
      &lt;xs:element maxOccurs="1" minOccurs="1" ref="IDSession"/&gt;
      &lt;xs:element maxOccurs="1" minOccurs="1" ref="IPJoueur"/&gt;
      &lt;xs:element maxOccurs="1" minOccurs="0" ref="IDCoffre"/&gt;
      &lt;!-- Corps --&gt;
      &lt;xs:element maxOccurs="1" minOccurs="1" ref="TypAg"/&gt;
      &lt;xs:element maxOccurs="1" minOccurs="0" name="CauseRefus" type="string-1024"/&gt;
      &lt;xs:element maxOccurs="1" minOccurs="0" name="TypeRefus"&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base="string-1024"&gt;
            &lt;xs:enumeration value="DelaiIdentite"/&gt;
            &lt;xs:enumeration value="RejetIdentite"/&gt;
            &lt;xs:enumeration value="Interdit"/&gt;
            &lt;xs:enumeration value="AutoInterdit"/&gt;
            &lt;xs:enumeration value="OpVerrouille"/&gt;
            &lt;xs:enumeration value="Verrouille"/&gt;
            &lt;xs:enumeration value="Cloture"/&gt;
            &lt;xs:enumeration value="Autre"/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>The element ACCESREFUSE is the root of the xml.</p>
  
  <p>XML : </p>
  
  <pre><code> &lt;ACCESREFUSE&gt;
        &lt;dateEvt&gt;Tue Oct 15 11:45:48 CEST 2013&lt;/dateEvt&gt;
        &lt;hashJoueur&gt;0000000000000000000000000000000000000000&lt;/hashJoueur&gt;
        &lt;typAg&gt;JC&lt;/typAg&gt;
        &lt;causeRefus&gt;Interdit&lt;/causeRefus&gt;
        &lt;typeRefus&gt;Interdiction Temporaire&lt;/typeRefus&gt;
        &lt;idjoueur&gt;81.252.190.129&lt;/idjoueur&gt;
        &lt;idoper&gt;002&lt;/idoper&gt;
        &lt;idsession&gt;301090&lt;/idsession&gt;
        &lt;idevt&gt;0&lt;/idevt&gt;
        &lt;ipjoueur/&gt;
        &lt;idcoffre/&gt;
   &lt;/ACCESREFUSE&gt;
  </code></pre>
  
  <p>Any idea ?
  Thank you</p>