24

I am starting a new project where I have third party XSD. My Java application needs to generate, and readm XML messages that conform to this XSD. In the past I have used Apache XMLBeans for this. It looks like XMLBeans has been retired.

What is a good replacement for XMLBeans now that it has been retired? I have used XStream on other projects but I don't recall that XStream has the ability to generate Java classes from an XSD so I am thinking that it is not a good choice over XMLBeans for this use case. I have hundreds of types defined in the XSD and would really prefer not to have to create the hundreds of Java classes to represent them in Java by hand.

In other words, using the XStream example, I have a Person type (and 99 others) defined in the XSD. Using XMLBeans I can generate the Java classes to represent these objects, but using XStream I would need to create the Java classes (e.g. Person) by hand or using some other tool. What tool should I use in this case?

7
  • 1
    If you are using axis2, be sure to checkout the options they suggest in ADB, JiBX and XMLBeans (now retired) here. Jan 1, 2015 at 1:04
  • 1
    Why do you say XMLBeans is "retired"? Do you know any official statements?
    – marcolopes
    Jan 2, 2015 at 1:21
  • 2
    If you go to the xml beans site there is a banner at the top indicating the project has been retired: xmlbeans.apache.org
    – John
    Jan 5, 2015 at 19:28
  • 1
    Yes it does! Started this week! From that info i got here: attic.apache.org/projects/xmlbeans.html
    – marcolopes
    Jan 29, 2015 at 21:24
  • 1
    XMLBeans has been brought out of retirement and is being managed by the Apache POI PMC. xmlbeans.apache.org Jul 16, 2018 at 11:23

2 Answers 2

10

Have you looked at JAXB? I haven't done anything with either of these, but googling for "alternative to XMLBeans" brings up lots of references to this package. Here's an article that compares them...

http://blog.bdoughan.com/2012/01/how-does-jaxb-compare-to-xmlbeans.html

4
  • It looks like (so far) JAXB is going to provide exactly what we need. I was able to generate Java classes from the xsd (573 Java classes were generated). There was a 'property value already defined' error that came up that did not occur when I generated the XMLBeans classes. I was able to work around this issue for now (I'm guessing I will need to write a jaxb binding file for the permanent fix). Thanks for the help Steve it is very much appreciated.
    – John
    Jan 1, 2015 at 15:54
  • 1
    The only? problem with JAXB for me, is the "unmarshaller / marshaller" mess... :-\ XMLBeans is very simple and transparent. Also, i don't know how to implement a "xml database" (xmlbeans creates methods to manipulate the xml elments as a list or array)
    – marcolopes
    Apr 2, 2015 at 17:54
  • The issue we ran into was the issue with thread safe v. performance. Creating the context object is slow for very large xml. The marshaller and unmarshaller are NOT thread safe. More here: jaxb.java.net/guide/Performance_and_thread_safety.html and here: stackoverflow.com/questions/7400422/…
    – John
    Jul 6, 2015 at 13:33
  • A recent link to the mentioned performance and thread safety. The repo is at github.com/javaee/jaxb-v2
    – SubOptimal
    Apr 12, 2018 at 6:08
3

XMLBeans has been unretired:

The Apache POI project has unretired the XMLBeans codebase and is maintaining it as a sub-project. Until now the XMLBeans codebase was held in the Apache Attic where former Apache projects are kept for the public good.

The latest release as of August 2020 is:

3.1.0 (March 26, 2019)

Having said that, I am not sure I would recommend using it, based on its history of retirement. Other solutions, such as JAXB, might be prefered since it will probably be better maintained in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.