• 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

UnMarshalling and Marshalling

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am evaluating JAXB and Castor for UnMarshalling(XML-> Java Objects ) and Marshalling(Java Objects -> XML). Which gives better performance ?
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure about CASTOR but JAXB has performance issue when you have lot of data. I have faced it, the data gets returned in 2 second but while marshalling takes lot of time and gives us out of memory error. This could be due to the xml element names(more than 15 characters in some case) in my xsd.

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also look at JIBX, if performance is a serious consideration.
 
kri shan
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anurag, How xml element names more than 15 characters in xsd gives outOfMemoryError ?

 
Anurag Blore
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Krishan,

May be I was not clear in my post.

In my case we have a search and if user searched based on 2 characters then the reult returned from the database is huge and data is returned fast from the database but when we do marshalling in java It gives us heap error. Just to mention my xml result is quite complex(In the sense it has relations,attributes etc returned) So If I am returning detail of one result the xml will be big and multiple result will have more data to convert our java object to xml(marshalling). It my guess the xml contains lot of Strings attribute name and this could be the cause.

If you think I am missing something please providie your thoughts.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Vote will go for JAXB. With a little trick we can save lot of JAXB marshalling and unmarshalling time. JAXB spends most of the time to create JAXB context. We just have to make JAXBContext static final. If you are using multiple JAXBContext, create 1st time and keep in static Hashmap.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I haven't evaluated JAXB for performance. But one advantage I found with CASTOR was that it does not mandate the use of XSDs.

Databases can return entire ResultSets as XML which you can then transform to whatever format you want using XSLT. But again, I am not sure if the transformation itself can throw OutOfMemoryError in your case
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JAXB doesn't need a schema; we're doing unmarshalling of a 6 MB file using JAXB, just by defining the appropriate classes with JAXB annotations. We only create the JAXBContext once.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I did some research on this and found that ,apache XMLBeans seems to be faster in marshalling and unmarshalling and also CPU utilization is less.

-Jegan
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe I'm being unfair to Castor, but at one time it was the only game in town, and it did a good job. These days, you don't hear that much about it, so I'm thinking that it no longer is the optimal tool for most tasks. In fact, I think that the JOnAS project switched from Castor to Zeus, and then abandoned Zeus for something more along the lines of a mainstream standard.

Of course, there also seemed to be a certain amount of ill-will among some because Castor claimed the acronym JDO, despite the conflict with the real JDO, so some of that could be politics.

On the inbound side, the Apache Digester remains popular. I've also used STaX where I wanted directed streaming input.

Finally, there are some JPA implementations that can persist to/from XML, if that's useful.
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can have a look at this : http://xstream.codehaus.org/
 
Oh. Hi guys! Look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic