title: JAXB Unmarshaller - Unexpected element Exception
body: <p>I'm using the JAXB parser to convert XML sent via an http request to a Java object while validating it against my XSD schema. The problem is that when the unmarshal() method is called it raises this exception:</p>
  
  <blockquote>
    <p>javax.xml.bind.UnmarshalException: unexpected element
    (uri:"<a href="http://www.somedomain.com/" rel="nofollow">http://www.somedomain.com/</a>", local:"assign"). Expected elements
    are (none)</p>
  </blockquote>
  
  <p>If I remove the namespace from my root XML element it raises the same exception with the uri portion being empty:</p>
  
  <blockquote>
    <p>javax.xml.bind.UnmarshalException: unexpected element
    (uri:"", local:"assign"). Expected elements
    are (none)</p>
  </blockquote>
  
  <p>The unmarshalling code:</p>
  
  <pre><code>            ServletInputStream xmlFile = request.getInputStream();
  
              SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
              Schema schema = sf.newSchema(new File("PatientAssignment.xsd"));
  
              JAXBContext jc = JAXBContext.newInstance(AssignType.class);
  
              Unmarshaller unmarshaller = jc.createUnmarshaller();
              unmarshaller.setSchema(schema);
              unmarshaller.setEventHandler(new AssignValidationEventHandler(patientResponses));
              assignments = (AssignType) unmarshaller.unmarshal(xmlFile);
  </code></pre>
  
  <p>My Java class and package-info.java:</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "AssignType", namespace = "http://www.somedomain.com/", propOrder = {
      "patient"
  })
  public class AssignType {
      @XmlElement(namespace = "http://www.somedomain.com/", required = true)
      protected List&lt;PatientAssignType&gt; patient;
  
      /* Getters and setters ommitted */
  }
  
  // package-info.java
  @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.somedomain.com/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
  </code></pre>
  
  <p>The XML I'm trying to parse:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;assign xmlns="http://www.somedomain.com/"&gt;
      &lt;patientAssign xmlns="http://www.somedomain.com/"&gt;
          &lt;firstName&gt;Buddy&lt;/firstName&gt;
          &lt;lastName&gt;Holly&lt;/lastName&gt;
          &lt;email&gt;&lt;/email&gt;
          &lt;dob&gt;&lt;/dob&gt;
          &lt;phone&gt;&lt;/phone&gt;
                  ...
      &lt;/patientAssign&gt;
  &lt;/assign&gt;
  </code></pre>
  
  <p>If anyone could tell me where I'm going wrong, it'd be much appreciated!</p>