views:

2350

answers:

9

It's been a while since I used Java in anger so please forgive me if this is silly.

I have just got started on a Java project where we are using JAXB to de-serializing an incoming XML string (from Jetty Server). The project is only using JAXB for this situation.

What are the alternatives to JAXB?
What are pros/cons of JAXB to these alternatives

I have done some googling and found lots of reference material, but is there a definitive source that is the goto place for JAXB questions or do people just see what people are doing and interpret from there.

Thanks.

+2  A: 

I have been using JAXB for a few projects. I think the best thing about it is it's integration with newer technologies like JAX-WS and JAX-RS (JSR 311, Restful spec).

If you are handling incoming XML as a String with Jetty, I would seriously consider looking into the JAX-RS. It handles all of the JAXB binding stuff for you and you just work with an object.

I've been pretty happy with JAXB through CXF for both REST style and SOAP web services.

Chris Dail
A: 

For alternatives to JAXB you might want to check out XFire (http://xfire.codehaus.org/) or Axis2 (http://ws.apache.org/axis2/). Those seem to be 2 popular alternatives, and I believe both are now JAX-WS complaint.

Flynn81
+6  A: 

I've found JAX-B pretty useful and actually like it better than many of the alternatives, especially if I'm starting from scratch and generating a schema from Java objects rather than Java objects from a schema.

In my experience, for whatever reason, I've found good documentation hard to come by from just Google searches. The best electronic documentation is provided in the JAX-B download where you'll also find numerous examples. "SOA Using Java Web Services" also has a good overview.

As for alternatives, there is:

and probably several more.

Dave Ray
+3  A: 

XML Bean comes to mind (http://xmlbeans.apache.org/)

One of the PROS about JAXB is that it now comes bundle in with JDK6. The generate output is really tight and efficient. We are currently converting all our XML Bean implementation to use JAXB 2. The big CONS that we have seen is the lack of XSD related operations.

Nik
Another big PROS, that I've discovered with JAXB, is that is now the defacto for all JAX-WS bindings. It's always nice to not have to add tons of 3rd party extension to your project; Most of the other XML streaming technology will ask you to add Apache Commons.
Nik
The last time I used XML Beans it leaked roughly 100% of instantiated classes. When trying to find out why I had a look at some of the wildest source code I've seen, so we stopped using it. That's 2-3 years ago, so it might be better now.
Peter Becker
JAXB is also now the defacto binding for JAX-RS for building REST services in Java.
Blaise Doughan
A: 

XStream is really good if you have an object model for the xml you are trying to parse.

Milhous
XStream can't deal properly with namespaces, though. I'd consider it a major drawback.
duffymo
+1  A: 

I have tried many of the listed suggestions and prefer Simple to them all. It is relatively new in the overall sense yet mature and stable, and seems to have taken a lot of the complaints from other XML frameworks into account. I highly suggest reading the front page and if possible giving it a quick proof of concept prototype in your project.

http://simple.sourceforge.net/

Pete
A: 

Other alternatives could be Castor, JibX, XMLBeans, or JDOM.

duffymo
A: 

Actually I had used Castor. It is better than JAXB in case of xml binding. It provides functionality to map your existing java beans.

Silent Warrior
JAXB is also able to map your existing Java beans.
Blaise Doughan
A: 

Look here: http://jcp.org/en/jsr/all for JSR-222. This Java Specification Request specifies the standard (non-free).

fubra