users@jaxb.java.net

Re: javax.xml.bind.UnmarshalException: Unexpected end of element {}:

From: Sriram Thyagarajan <Sriram_Thyagarajan_at_KEANE-NNE.com>
Date: Wed, 30 Apr 2003 17:06:49 -0400

I have my own even Handler and it catches other validation events related to
date conversion

      _jaxbContext = JAXBContext.newInstance(packageName);
      _unMarshaller = _jaxbContext.createUnmarshaller();

      //Set the event handler
      _xmlValidationEventsHandler = new XmlValidationEventsHandler();
      _unMarshaller.setEventHandler(_xmlValidationEventsHandler);

      //Set the validation to true
      _unMarshaller.setValidating(true);

All that the event Handler does is create an list (I did this, so that I can
process or ignore as needed)

  public boolean handleEvent(ValidationEvent event) {
    boolean returnFlag = true;
    if (event.getSeverity() == ValidationEvent.FATAL_ERROR) {
      //Stop when there is a fatal error
      returnFlag = false;
    } else {
      boolean ignorableEvent = checkIfIgnorable(event);
      if (!ignorableEvent) {
        if (_validationsEvents == null) {
          _validationsEvents = new ArrayList();
        }
        _validationsEvents.add(event);
      }
    }
    return returnFlag;
  }



-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Wednesday, April 30, 2003 3:41 PM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: javax.xml.bind.UnmarshalException: Unexpected end of
element {}:


Judging from the error message, it seems like your XML parser is not
configured properly (you forgot to call the setNamespaceAware method)

Which version of the unmarshal method are you using?

regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com