Alex Staveley is a software professional passionate about software engineering and technical architecture. He blogs about architectural approaches, Java topics, web solutions and various technical bits and pieces. Alex is a DZone MVB and is not an employee of DZone and has posted 48 posts at DZone. You can read more from them at their website. View Full User Profile

What are the differences between JAXB 1.0 and JAXB 2.0

  • submit to reddit

What are the differences between JAXB 1.0 and JAXB 2.0?

  1. JAXB 1.0 only requires JDK 1.3 or later. JAXB 2.0 requires JDK 1.5 or later.
  2. JAXB 2.0 makes use of generics and thus provides compile time type safety checking thus reducing runtime errors.
  3. Validation is only available during marshalling in JAXB 1.0. Validation is also available during unmarshalling in JAXB 2.0.
  4. Termination occurs in JAXB 1.0 when a validation error occurs. In JAXB 2.0 custom ValidationEventHandlers can be used to deal with validation errors.
  5. JAXB 2.0 uses annotations and supports bi-directional mapping.
  6. JAXB 2.0 generates less code.
  7. JAXB 1.0 does not support key XML Schema components like anyAttribute, key, keyref, and unique. It also does not support attributes like complexType.abstract, element.abstract, element.substitutionGroup, xsi:type, complexType.block,, element.block,, schema.blockDefault, and schema.finalDefault. In version 2.0, support has been added for all of these schema constructs.




Published at DZone with permission of Alex Staveley, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)



Blaise Doughan replied on Sun, 2012/01/01 - 3:55pm


  1. JAXB 2 models can be used with any JAXB runtime (Metro, MOXy, JaxMe), while JAXB 1 models must be used with the implementation that generated them.
  2. JAXB 2 is the standard binding layer for JAX-WS and JAX-RS.
  3. A JAXB 2 implementation is included in Java SE 6.
  4. JAXB 2 supports marshalling/unmarshalling StAX.
  5. JAXB 2 supports javax.xml.validation APIs for schema validation.  The JAXB Validator class is now deprecated.

Marc Stock replied on Fri, 2012/01/06 - 10:37am

JAXB 2.x is a lot faster too.

Anoop Hallimala replied on Mon, 2013/05/06 - 1:52am

 I am looking at some code before 1.5 Java and they have assumed that ""(Empty String) is getting converted to 0(Integer). When I tested this on the latest JRE, I found that this is not so and JAXB is converting "" to null, NOT 0. 

Have they changed the behavior for JAXB? Or, the people who wrote those code are very wrong?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.