aspose file tools*
The moose likes XML and Related Technologies and the fly likes JaxB unexpected element (uri: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JaxB unexpected element (uri:"", local:"Installer")" Watch "JaxB unexpected element (uri:"", local:"Installer")" New topic
Author

JaxB unexpected element (uri:"", local:"Installer")

Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641
Hi, I am getting following error for given xsd and xml with jaxb unmarshalling

XSD



XML

JAVA CODE


Error



Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Installer"). Expected elements are <{http://www.some.com/TPS/Installer}CommonParams>,<{http://www.some.com/TPS/Installer}CreateAASServer>,<{http://www.some.com/TPS/Installer}CreateBulkerServer>,<{http://www.some.com/TPS/Installer}CreateDSJPay>,<{http://www.some.com/TPS/Installer}CreateDSNonXAJPay>,<{http://www.some.com/TPS/Installer}CreateDSPWH>,<{http://www.some.com/TPS/Installer}CreateDSPWHHistory>,<{http://www.some.com/TPS/Installer}CreateDatabase>,<{http://www.some.com/TPS/Installer}CreateDatabaseAAS>,<{http://www.some.com/TPS/Installer}CreateDatabaseBulker>,<{http://www.some.com/TPS/Installer}CreateDatabaseDirectory>,<{http://www.some.com/TPS/Installer}CreateDatabasePWH>,<{http://www.some.com/TPS/Installer}CreateDatabasePWH_H>,<{http://www.some.com/TPS/Installer}CreateQuartzTables>,<{http://www.some.com/TPS/Installer}CreateSepaDirectoryServer>,<{http://www.some.com/TPS/Installer}CreateSepaPaymentServer>,<{http://www.some.com/TPS/Installer}CreateServePWH>,<{http://www.some.com/TPS/Installer}CreateSpringBatchTables>,<{http://www.some.com/TPS/Installer}CreateTables>,<{http://www.some.com/TPS/Installer}CreateTablesAAS>,<{http://www.some.com/TPS/Installer}CreateTablesBulker>,<{http://www.some.com/TPS/Installer}CreateTablesDirectory>,<{http://www.some.com/TPS/Installer}CreateTablesPWH>,<{http://www.some.com/TPS/Installer}CreateTablesPWHHistoryConfig>,<{http://www.some.com/TPS/Installer}CreateTablesPWHSpringBatch>,<{http://www.some.com/TPS/Installer}CreateTablesPWH_H>,<{http://www.some.com/TPS/Installer}CreateUserGeneral>,<{http://www.some.com/TPS/Installer}Db2EnvAAS>,<{http://www.some.com/TPS/Installer}Db2EnvBulker>,<{http://www.some.com/TPS/Installer}Db2EnvDirectory>,<{http://www.some.com/TPS/Installer}Db2EnvGeneral>,<{http://www.some.com/TPS/Installer}DeleteSepaDirectoryServer>,<{http://www.some.com/TPS/Installer}DeleteServePWH>,<{http://www.some.com/TPS/Installer}DeleteServerBulker>,<{http://www.some.com/TPS/Installer}DisableConstraintsAAS>,<{http://www.some.com/TPS/Installer}DisableConstraintsBulker>,<{http://www.some.com/TPS/Installer}DisableConstraintsDirectory>,<{http://www.some.com/TPS/Installer}EnableConstraintsAAS>,<{http://www.some.com/TPS/Installer}EnableConstraintsBulker>,<{http://www.some.com/TPS/Installer}EnableConstraintsDirectory>,<{http://www.some.com/TPS/Installer}GrantPriviledgesBulker>,<{http://www.some.com/TPS/Installer}IncreaseLog>,<{http://www.some.com/TPS/Installer}IncreaseLogBulker>,<{http://www.some.com/TPS/Installer}InsertSeed>,<{http://www.some.com/TPS/Installer}InsertSeed1Directory>,<{http://www.some.com/TPS/Installer}InsertSeed2Directory>,<{http://www.some.com/TPS/Installer}InsertSeed3Directory>,<{http://www.some.com/TPS/Installer}InsertSeedAAS>,<{http://www.some.com/TPS/Installer}InsertSeedBulker>,<{http://www.some.com/TPS/Installer}InstallAASServer>,<{http://www.some.com/TPS/Installer}InstallBulkerServer>,<{http://www.some.com/TPS/Installer}InstallPWHServer>,<{http://www.some.com/TPS/Installer}InstallSepaDirectoryServer>,<{http://www.some.com/TPS/Installer}InstallSepaPaymentServer>,<{http://www.some.com/TPS/Installer}MQEnvBulker>,<{http://www.some.com/TPS/Installer}MQEnvCommonQGeneral>,<{http://www.some.com/TPS/Installer}MQEnvDirectory>,<{http://www.some.com/TPS/Installer}MQEnvGeneral>,<{http://www.some.com/TPS/Installer}MQEnvJPay>,<{http://www.some.com/TPS/Installer}MQEnvQFGeneral>,<{http://www.some.com/TPS/Installer}MailEnvDirectory>,<{http://www.some.com/TPS/Installer}Phase>,<{http://www.some.com/TPS/Installer}SetupCacheMQDirectory>,<{http://www.some.com/TPS/Installer}SetupMQBulker>,<{http://www.some.com/TPS/Installer}SetupMQProPay>,<{http://www.some.com/TPS/Installer}SetupServices>,<{http://www.some.com/TPS/Installer}SetupServicesBulker>,<{http://www.some.com/TPS/Installer}StepParams>,<{http://www.some.com/TPS/Installer}Steps>,<{http://www.some.com/TPS/Installer}TimeManagerEnvBulker>,<{http://www.some.com/TPS/Installer}VirtualHostGeneral>,<{http://www.some.com/TPS/Installer}WorkManagerEnvBulker>
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:254)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:249)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1049)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:478)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:459)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184)
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 com.some.tps.installer.utils.XMLParser.praseDocument(XMLParser.java:18)
at com.some.tps.installer.InstallManager.main(InstallManager.java:35)



-P


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

The unmarshaller found an Installer element which isn't in any namespace. Which it didn't expect. I'm no schema expert, but doesn't that schema specify an Installer element which is in the "http://www.some.com/ABC/Installer" namespace?
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641
Hi Paul,

I have defined Installer as follows, its root element.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

I'm sorry, I can't see how that differs from the schema in your original post. Could you point out the difference which fixed the problem?
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641
Hey, sorry for delay in reply, I used Eclipse plugin to generate sample xml from xsd, and used those tags in my xml, the main change is to use prefix for xml tag

before ----


fix :-



So basically <Installer> needs to be <installer:Installer>

-P
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641
duplicate by mistake
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JaxB unexpected element (uri:"", local:"Installer")