• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with use Castor from Spring OXM.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all! I had a problem with unmarshalling xml. More details:

I've a XML file:


Also, I've Contractor pojo.


So, I use Castor for unmarshall xml.

Castor mapping file:


Spring configuration:


Finally, I get list of contractor:


After run, I've follow error:
Caused by: org.xml.sax.SAXException: unable to find FieldDescriptor for 'contractor' in ClassDescriptor of contractors
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:2020)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1436)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:748)
... 9 more

Can I get list of Contractor without wrapper object? Please, help!
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This post might get a better response in the XML forums. From what I have done with Castor I have not found an answer to this riddle that I am satisfied with. If you are concerned primarily with unmarshaling you can skip using springs unmarshaller and use Castors directly. Their unmarshaller allows you to pass in an object. You can do something similar to



This process instructs the Unmarshaller to expect an ArrayList as the
root element, and it will use the mapping file for classes contained
inside the ArrayList.

Personally I think this ends up being more of a hack than just creating the wrapper object and being done with it though.

Also on a side note I would avoid doing things like this:



You may have been doing that just for illustration but just in case you were not, it defeats the purpose of dependency injection. This should be wired in from your bean configuration or via annotations like @Autowired etc.
 
Vladimir Koba
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply!
 
Ranch Hand
Posts: 128
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have somehow missed something in the castor mapping file. Change line 4 to and add another class element in the castor mapping that will map to contractors tag.
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also if you are using introspection auto-complete is spelled wrong
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic