UnmarshalException: unexpected element

Posted by Tom Brito on Stack Overflow See other posts from Stack Overflow or by Tom Brito
Published on 2010-03-08T18:54:52Z Indexed on 2010/03/08 19:06 UTC
Read the original article Hit count: 430

Filed under:
|
|
|
|

I'm working with JAXB, and I'm having trouble to unmarshall a file;

The following lines, on the beginning of the file, are causing trouble:

<!DOCTYPE package
PUBLIC "+//ISBN 0-9673008-1-9//DTD OEB 1.2 Package//EN" "http://openebook.org/dtds/oeb-1.2/oebpkg12.dtd">
<package xmlns="http://openebook.org/namespaces/oeb-package/1.0/" unique-identifier="uid">

If I delete all the !DOCTYPE it gives no Exception, but it doesn't load any value either.

The program (with the !DOCKTYPE) is throwing the exeption:

javax.xml.bind.UnmarshalException: unexpected element (uri:"http://openebook.org/namespaces/oeb-package/1.0/", local:"package"). Expected elements are <{}dc-metadata>,<{}dc:Contributor>,<{}dc:Coverage>,<{}dc:Creator>,<{}dc:Date>,<{}dc:Description>,<{}dc:Format>,<{}dc:Identifier>,<{}dc:Language>,<{}dc:Publisher>,<{}dc:Relation>,<{}dc:Rights>,<{}dc:Source>,<{}dc:Subject>,<{}dc:Title>,<{}dc:Type>,<{}guide>,<{}item>,<{}itemref>,<{}manifest>,<{}meta>,<{}metadata>,<{}package>,<{}reference>,<{}site>,<{}spine>,<{}tour>,<{}tours>,<{}x-metadata>

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:631)

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:236)

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:231)

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:105)

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1038)

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:467)

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:448)

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:137)

      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)

      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:767)

      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)

      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)

      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3103)

      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922)

      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)

      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)

      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)

      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)

      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)

      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)

      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)

      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:200)

      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:173)

      at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)

      at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:142)

      at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:151)

      at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:169)

      at br.usp.lsi.pdtb.protector.view.ProtectorView.showBookData(ProtectorView.java:55)

      at br.usp.lsi.pdtb.protector.ProtectorImpl.openBook(ProtectorImpl.java:43)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at tomPack.swing.TomAction.actionPerformed(TomAction.java:115)

      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)

      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)

      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)

      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)

      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)

      at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)

      at java.awt.Component.processMouseEvent(Component.java:6263)

      at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)

      at java.awt.Component.processEvent(Component.java:6028)

      at java.awt.Container.processEvent(Container.java:2041)

      at java.awt.Component.dispatchEventImpl(Component.java:4630)

      at java.awt.Container.dispatchEventImpl(Container.java:2099)

      at java.awt.Component.dispatchEvent(Component.java:4460)

      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)

      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)

      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)

      at java.awt.Container.dispatchEventImpl(Container.java:2085)

      at java.awt.Window.dispatchEventImpl(Window.java:2478)

      at java.awt.Component.dispatchEvent(Component.java:4460)

      at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)

      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)

      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)

      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Any idea how to solve this?

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml