Home » Tag Archives: JAXB (page 3)

Tag Archives: JAXB

Rest using Jersey – Complete Tutorial with JAXB, Exception Handling and Client Program


Recently I started working on a Restful web service project using Jersey API. There are some tutorials available online but I faced some issues with exception handling and I didn’t found anywhere complete project using JaxB and providing exception handling approach. So once I was able to create a Restful web service using Jersey API with exception handling and client ...

Read More »

JAXB and Root Elements


@XmlRootElement is an annotation that people are used to using with JAXB (JSR-222). It’s purpose is to uniquely associate a root element with a class. Since JAXB classes map to complex types, it is possible for a class to correspond to multiple root elements. In this case @XmlRootElement can not be used and people start getting a bit confused. In ...

Read More »

JAXB – No Annotations Required


There appears to be a misconception that annotations are required on the model in order to use a JAXB (JSR-222) implementation. The truth is that JAXB is configuration by exception, so annotations are only required when you want to override default behaviour. In this example I’ll demonstrate how to use JAXB without providing any metadata. Domain Model I will use ...

Read More »

EclipseLink MOXy as a JAXB provider


EclipseLink MOXy is a JAXB provider and is a compelling alternative to the default JAXB provider built into JDK. First a simple test to marshal a Java object to XML: This is the model: @XmlRootElement(name='MemberDetailsRequest', namespace='http://bk.org/memberservice/') @XmlAccessorType(XmlAccessType.FIELD) public class MemberDetailsRequest { public MemberDetailsRequest() { } public MemberDetailsRequest(Long id) { this.id = id; } private Long id; public Long getId() { ...

Read More »

Approaches to XML – Part 3 – JAXB


If you remember from Part 1 and Part 2, I’m covering different approaches to parsing XML messages using the outrageously corny scenario of Pete’s Perfect Pizza, the pizza company with big ideas. In this story, you are an employee of Pete’s and have been asked to implement a system for sending orders from the front desk to the kitchen and you came ...

Read More »

JAXB Custom Binding – Java.util.Date / Spring 3 Serialization


JaxB can handle Java.util.Date serialization, but it expects the following format: “yyyy-MM-ddTHH:mm:ss“. What if you need to format the date object in another format? I had the same issue when I was working with Spring MVc 3 and Jackson JSON Processor, and recently, I faced the same issue working with Spring MVC 3 and JAXB for XML serialization. Let’s digg ...

Read More »

XML unmarshalling benchmark: JAXB vs STax vs Woodstox


Introduction Towards the end of last week I started thinking how to deal with large amounts of XML data in a resource-friendly way.The main problem that I wanted to solve was how to process large XML files in chunks while at the same time providing upstream/downstream systems with some data to process. Of course I’ve been using JAXB technology for ...

Read More »

GlassFish 3.1.2 is Full of MOXy (EclipseLink JAXB)


I am very happy to announce that EclipseLink JAXB (MOXy) is now a JAXB ( JSR-222) provider in GlassFish 3.1.2. I would like to thank the EclipseLink and GlassFish committers for all their hard work to make this happen. In this post I will introduce how MOXy can be leveraged to create a JAX-WS service. In future posts I will ...

Read More »

JAXB and Unmapped Properties


JAXB (JSR-222) is configuration by exception, meaning that there is a default mapping applied to domain objects. This means that sometimes you need to explicitly exclude a field/property. In this post I’ll discuss how this can be done using @XmlTransient or @XmlAccessorType(XmlAccessType.NONE) and when each option is appropriate. @XmlTransient When you mark a field/property with @XmlTransient you are explicitly telling ...

Read More »

Implementing Active Record Pattern with Spring AOP


During class design we should take decisions about the assignment of responsibilities that will have every class. If we have chosen well, systems tend to be easier to understand, maintain and extend. Almost all of our projects have a persistence layer, either relational database, document stores, or simply XML files. And typically you will use DAO pattern to implement abstract ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.