aspose file tools*
The moose likes Performance and the fly likes UnMarshalling and Marshalling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "UnMarshalling and Marshalling" Watch "UnMarshalling and Marshalling" New topic
Author

UnMarshalling and Marshalling

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
I am evaluating JAXB and Castor for UnMarshalling(XML-> Java Objects ) and Marshalling(Java Objects -> XML). Which gives better performance ?
Anurag Blore
Ranch Hand

Joined: Jan 15, 2003
Posts: 74
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.

Taariq San
Ranch Hand

Joined: Nov 20, 2007
Posts: 192
Also look at JIBX, if performance is a serious consideration.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
Hi Anurag, How xml element names more than 15 characters in xsd gives outOfMemoryError ?

Anurag Blore
Ranch Hand

Joined: Jan 15, 2003
Posts: 74
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.
Hiren Dutta
Greenhorn

Joined: Dec 30, 2005
Posts: 10
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.
Bhaskar Rao
Greenhorn

Joined: Apr 25, 2005
Posts: 23
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
Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

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.
Jegan Thangavelu
Greenhorn

Joined: Nov 09, 2006
Posts: 1

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
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Praveen Sharma
Ranch Hand

Joined: Jul 31, 2008
Posts: 129
You can have a look at this : http://xstream.codehaus.org/


SCJP 80% SCWCD 89%
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: UnMarshalling and Marshalling
 
Similar Threads
XML Marshalling and UnMarshalling
Marshalling and UnMarshalling
DWR vs. GWT
What are the ways to convert java type to xsd type?
compare two XML files using DOM parser