I used XStream many years ago, but I see that the libraries is not updated since 2008 (latest news). Is there now a more modern and up to dates Java XML serialization library?
-
2As of August 2011, XStream has just had it's [first major update in 3 years](http://xstream.codehaus.org/news.html#1.4). This pace of development seems appropriate since as other answers have explained, XStream is a mature project. – Justin Emery Apr 09 '13 at 22:12
-
And indeed, the updates continue: "February 8, 2014 XStream 1.4.7 released". – Stephen C Jan 29 '15 at 22:32
-
You can now get XStream from Github, and the documentation is published on github.io. At this point in time the "theory" that the library is not being maintained / updated is thoroughly debunked. – Stephen C Jun 25 '19 at 13:26
-
2021 and it still works for me. Many use cases. I am not sure how fast it is though. – mjs Jul 19 '21 at 18:20
6 Answers
In order of preference, relevancy and activity:
JAXB
Visit the JAXB project's site to check out the tutorial and guide. Have also a look at the original JAXB architecture whitepaper.
The JAXB projet listed above is the reference implementation of the API, and is packaged in by the GlassFish Application Server.
EclipseLink's MOXy
Visit the EclipseLink project's site and read this introductory article to EclipseLink on InfoQ, and see Blaise Doughan's answer about MOXy.
EclipseLink originated from Oracle's TopLink and is now open source, managed by the Eclipse Foundation, and used in a number of Eclipse-based products.
XStream
Yes, XStream, because it's actually been updated in 2011 with a major update and 2 service releases since you asked, so it seems well-maintained and a pretty good contender used by mature projects. Don't forget to check what's new in version 1.4.x.
Visit the XStream project's site and its tutorial to compare.
XmlBeans
Visit the XmlBeans project's site.
XmlBeans is a well-tested project that has been around for a while.
JiBX
Visit the JiBX project's site, follow the tutorial and guide.
JiBX might be a simpler alternative if you don't like the complexity of XmlBeans or even JAXB.
-
+1 for JAXB. XMLBeans on the other hand has not released since July 2008, which puts it in a similar position to XStream as far as the OP is concerned: http://xmlbeans.apache.org/sourceAndBinaries/index.html – bdoughan May 28 '11 at 10:58
-
1@Blaise: True, I know. But I've had good experiences with it. Plus, as mentioned in another answer by Steven C., the fact that it's outdated doesn't always mean it's bad. Maybe it means it's good enough to not need a new release, though I would usually be suspicious about it. – haylem May 28 '11 at 11:02
-
@Blaise: but actually, I realized I forgot EclipseLink, which I also like, and is used in a lot of Eclipse-based solutions (and others) and is actively developed. So I'd rate it above XmlBeans as well. – haylem May 28 '11 at 11:10
-
@Blaise: whoops, hadn't even noticed your answer, actually. I'm crediting you directly then. – haylem May 28 '11 at 11:12
Note: I'm the EclipseLink JAXB (MOXy) lead, and a member of the JAXB (JSR-222) expert group.
You are correct in considering a libraries release frequency when making a software choice. There are many reasons for a new product release:
- Customer Requests - No matter how good your library is, your user base will have improvement suggestions and feature requests.
- Industry Developments - Modular deployment is hot topic right now, over the past few years changes had to be made to EclipseLink to make it compatible with OSGi.
- New Java Versions - Java SE 7 will be released soon, while this does not necessitate a release we did need to make some tweaks in our upcoming release to ensure we were compatible. Also over time more features will be added to leverage new Java aspects (EclipseLink requires a minimum of Java SE 5).
Another important aspect of evaluating any open source project is the number of active committers. Sites like ohloh.net are useful for that:
JAXB (JSR-222)
JAXB is more than an implementation, it is a standard that is developed through the Java Community Process (JCP). There have been participants from such object-to-XML libraries as XML Beans (BEA), EMF (IBM), TopLink (Oracle), etc. Because JAXB is part of Java EE it is available in every application server: WebLogic, GlassFish, WebSphere, JBoss, etc.
JAXB Offers:
- 100% schema coverage
- Multiple implementations: Metro, EclipseLink MOXy, Apache JaxMe, etc
- Included in Java SE 6, compatible with JDK 1.5
- Ability to start from XML schema or Java classes
- Various extension mechanisms including XmlAdapter - Example
- Option to preserve XML infoset via Binder - Example
- Binding layer for JAX-WS (Web Services)
- Binding layer for JAX-RS (Rest) - Example
- Compatible with JSON (when used with libraries such as Jettison) - Example
EclipseLink JAXB (MOXy)
MOXy is a JAXB implementation that offers many useful extensions, including:
True Object to XML Mapping by Leveraging XPath
XPath based mapping allows you to start with both Java classes and an XML schema and map the two together.
- http://bdoughan.blogspot.com/2010/09/xpath-based-mapping-geocode-example.html
- http://bdoughan.blogspot.com/2011/03/map-to-element-based-on-attribute-value.html
Mapping File for Handling 3rd Party Classes
In the current JAXB spec the metadata is supplied via annotations. This can be problematic to use with 3rd party classes that cannot be modified. This is why MOXy offers a way to specify the mappings via XML:
- http://bdoughan.blogspot.com/2010/12/extending-jaxb-representing-annotations.html
- http://bdoughan.blogspot.com/2011/04/moxys-xml-metadata-in-jax-rs-service.html
Extensions for Mapping JPA Entities
Often times you need to do more with your Java objects then just map then to XML. You may also need to persist them to a database. This means your object model may have additional constraints on it that you need to account for. MOXy offers a number of extensions for this kind of use case:
- http://bdoughan.blogspot.com/2010/07/jpa-entities-to-xml-bidirectional.html
- http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA
Comparisons
Below are a couple comparisons I have done comparing JAXB to XStream and Simple:
-
No issues with XStream here, plenty with JAXB and Hessian. JAXB is not a able to deserialize like XStream is. See https://stackoverflow.com/questions/68454607/jboss-river-serialization-library-java-lang-negativearraysizeexception-on-certa – mjs Jul 20 '21 at 16:55
The fact that something hasn't been updated for 3 years doesn't mean that it is out of date. It might simply mean that there has been no need to update it. If there is no need to change a project, why change it?
Another explanation for the apparent lack of "progress" is that changing library APIs tends to be disruptive to projects that depend on them. This is particularly problematic for projects that combine lots of third-party components and libraries into one Java application.
Looking for alternatives to a library is a good thing, but simply doing this because the library hasn't been updated recently is not. If XStream does what you need, stick with it. Newer doesn't necessarily mean better.
UPDATE - 2019
XStream has been receiving updates with a new release at least once a year since 2011. Refer to the Changes page for details, and look at the activity on the Github repository for the project. As of now, the theory that XStream is not being maintained is (IMO) thoroughly debunked.

- 698,415
- 94
- 811
- 1,216
XStream is pretty good and it does it's job well. Even for recent projects, I prefer to use XStream for use cases where it fits because it's easy to use, lightweight, and performs really well.
If you are looking at some serious bean-binding work, take a look at Simple Framework. It's also a good tool. This helped me out in one project where I needed to do some serious custom mapping work with annotations. http://simple.sourceforge.net/

- 6,840
- 3
- 46
- 63
XStream 1.4.6 was released in Dec 2013, with Java 8 improvements, so the library HAS been updated since 2008.

- 278
- 1
- 13
Underscore-java can read and write xml files. I am the maintainer of the project. Java 11+ is supported.

- 2,029
- 1
- 24
- 31