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.
Also look at JIBX, if performance is a serious consideration.
Joined: Apr 08, 2004
Hi Anurag, How xml element names more than 15 characters in xsd gives outOfMemoryError ?
Joined: Jan 15, 2003
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.
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.
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
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.
An IDE is no substitute for an Intelligent Developer.