title: JAXB ValidationEventHandler's handleEvent method not being called
body: <p>I am trying to capture a <code>ValidationEvent</code> with characters that are not allowed in the XML rules. (e.g, "&amp;") 
  Also, I set up <code>ValidationEventHandler</code> to check for unmarshal errors. <strong>I tried to unmarshal using an <code>InputStream</code>, but the event handler does not catch the error.</strong> The <code>handleEvent</code> method is not executed at all. On the other hand, using <code>StringReader</code> will work normally.</p>
  
  <p>I've already read the Javadoc that describes the <code>unmarshal</code> method. However, I did not see that it could not capture the ValidationEvent. </p>
  
  <blockquote>
    <p>Unmarshal XML data from the specified InputStream and return the resulting content tree.  Validation event location information may be incomplete when using this form of the unmarshal API.</p>
  </blockquote>
  
  <p>On the last attempt, I did try searching online but I couldn't find anything. <br/> Any help will be appreciated :D</p>
  
  <h3>Extra question:</h3>
  
  <p>I am sorry to add a question. (The POJO class has changed a bit ...)
  I defined <strong>the POJO class field with <code>@XmlPath</code> Annotation differently from the XML element name</strong>, but it does not seem to work. Should I use it as an XmlElement?</p>
  
  <hr>
  
  <h3>POJO class:</h3>
  
  <pre class="lang-java prettyprint-override"><code>import org.eclipse.persistence.oxm.annotations.XmlPath;
  
  import javax.xml.bind.annotation.XmlAttribute;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  import java.util.List;
  
  @XmlRootElement
  class Article {
      private String title;
      private String category;
      private List&lt;ArticleImage&gt; imageList;
  
      public String getTitle() {
          return title;
      }
  
      @XmlElement
      public void setTitle(String title) {
          this.title = title;
      }
  
      public String getCategory() {
          return category;
      }
  
      @XmlElement
      public void setCategory(String category) {
          this.category = category;
      }
  
      public List&lt;ArticleImage&gt; getImageList() {
          return imageList;
      }
  
      // for Extra Question... :D
      @XmlPath("image")
      public void setImageList(List&lt;ArticleImage&gt; imageList) {
          this.imageList = imageList;
      }
  }
  
  class ArticleImage {
      private String url;
      private String ext;
  
      public String getUrl() {
          return url;
      }
  
      @XmlAttribute
      public void setUrl(String url) {
          this.url = url;
      }
  
      public String getExt() {
          return ext;
      }
  
      @XmlAttribute
      public void setExt(String ext) {
          this.ext = ext;
      }
  }
  </code></pre>
  
  <p><br/></p>
  
  <h3>ValidationEventHandler:</h3>
  
  <pre class="lang-java prettyprint-override"><code>import javax.xml.bind.ValidationEvent;
  import javax.xml.bind.ValidationEventHandler;
  import javax.xml.bind.ValidationEventLocator;
  
  class CustomValidationHandler implements ValidationEventHandler {
  
      // This method is not reached when debugging.
      @Override
      public boolean handleEvent(ValidationEvent event) {
          if (event.getSeverity() == ValidationEvent.FATAL_ERROR ||
                  event.getSeverity() == ValidationEvent.ERROR) {
              ValidationEventLocator locator = event.getLocator();
              throw new RuntimeException("Error in EventHandler. line number: " + locator.getLineNumber());
          }
          return true;
      }
  }
  </code></pre>
  
  <p><br/></p>
  
  <h3>Unmarshal code:</h3>
  
  <pre class="lang-java prettyprint-override"><code>import org.eclipse.persistence.jaxb.JAXBContextFactory;
  import javax.xml.bind.JAXBContext;
  import javax.xml.bind.Unmarshaller;
  import java.io.ByteArrayInputStream;
  import java.io.InputStream;
  
  public class SomeTest {
  
      public void someMethod() {
          String xmlString = "&lt;article type=\"item\"&gt;\n"
                  + "    &lt;title&gt;M&amp;A&lt;/title&gt;\n"
                  + "    &lt;category&gt;1234-1234&lt;/category&gt;\n"
                  + "    &lt;image url=\"hello\" ext=\"jpg\"/&gt;\n"
                  + "&lt;/article&gt;";
  
          try (InputStream fileInputStream = new ByteArrayInputStream(xmlString.getBytes())) {
              JAXBContext context = JAXBContextFactory.createContext(new Class[]{Article.class}, null);
              Unmarshaller unmarshaller = context.createUnmarshaller();
              unmarshaller.setEventHandler(new CustomValidationHandler());
              Article article = (Article) unmarshaller.unmarshal(fileInputStream);
  
              System.out.println(article.getTitle());
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      public static void main(String[] args) {
          new SomeTest().someMethod();
      }
  }
  </code></pre>