Showing posts with label Interface. Show all posts
Showing posts with label Interface. Show all posts

May 13, 2011

JAXB and Interface Fronted Models

Usually with JAXB we are mapping POJOs to XML.  In this example I will demonstrate how to handle a Java model that is exposed through a set of interfaces.   This post was inspired by an answer I gave (feel free to upvote) to a question on Stack Overflow.  In the question the poster was running into exceptions like the one below.  This post will cover how to properly map this use case.

Exception in thread "main" com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 6 counts of IllegalAnnotationExceptions
blog.interfaces.Customer is an interface, and JAXB can't handle interfaces.
 this problem is related to the following location:
  at blog.interfaces.Customer
blog.interfaces.Customer does not have a no-arg default constructor.
 this problem is related to the following location:
  at blog.interfaces.Customer
...

July 23, 2010

MOXy JAXB - Map Interfaces to XML

I recently came across a Twitter message (tweet) complaining that JAXB does not support binding Java interfaces to XML. Below I'll describe how this can be accomplished using MOXy in the upcoming EclipseLink 2.1.1 and 2.2 releases (try it now).