• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"AirAvailabilityRS")

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my scaled down XSD


Here is XML


Here is the unmarshalling code


I get this error

javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"AirAvailabilityRS"). Expected elements are <{http://farelogix.com/flx/tc}agent>,<{http://farelogix.com/flx/tc}iden>,<{http://farelogix.com/flx/tc}provider>,<{http://farelogix.com/flx/tc}script>,<{http://farelogix.com/flx/tc}tc>

Which is weird because the expected elements are for a different schema that is used in the soap header


Any help would be appreciated...

Thanks!
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am also facing sme issue.

could anyone please provide the solution?
 
Greenhorn
Posts: 7
Eclipse IDE Tomcat Server Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you guys fix the above issue? I am having the same problem.
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this code instead:
 
hemanth kollah
Greenhorn
Posts: 7
Eclipse IDE Tomcat Server Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply James, I have an unmarshal like below

private Setup unmarshal(DataHandler DataHandler, String jaxbPackageInstance)
throws Exception
{
JAXBContext jaxbContext = JAXBContext.newInstance(jaxbPackageInstance);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
return (Setup)unmarshaller.unmarshal(DataHandler.getDataSource().getInputStream());

}

When I execute this from my project it throws me an error message as below.

javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"setup"). Expected elements are (none)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:609)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:244)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:239)
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:1015)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:452)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:433)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:137)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
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:184)

Please letme know if I am missing something.

 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of:



Try:

 
hemanth kollah
Greenhorn
Posts: 7
Eclipse IDE Tomcat Server Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed my code with the proposed changes and now I get the below error message

javax.xml.bind.JAXBException: com.ec.copec.lw.configuration.Setup is not known to this context
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:587)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.getBeanInfo(UnmarshallerImpl.java:531)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:190)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:241)


I checked that Setup.java is already present in the Location where I need.
 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hemanth

Instead of:



Try:

 
hemanth kollah
Greenhorn
Posts: 7
Eclipse IDE Tomcat Server Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Much James, I have rebuild the Setup.java and ObjectFactory.java files using the XJC utility and replaced my project files with the new version of the files. I used your suggestion and that resolved the unmarshalleing error.

JAXBElement<Setup> root = unmarshaller.unmarshal(new StreamSource(DataHandler.getDataSource().getInputStream()), Setup.class);
return root.getValue();
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Boswell wrote:Instead of:



Try:



This solution worked for me!!  Thanks so much!

Since we use a third party xsd, I can't simply go changing the xsd with an annotion or anything, so this was really what I was looking for.
 
Could you hold this kitten for a sec? I need to adjust this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!