Q:

IllegalAnnotationsException SetMultimap is an interface, and JAXB can't handle interfaces

I have the following code:
private SetMultimap<String, Dynamic> dynamicFields = TreeMultimap.create(Ordering.natural(), new Comparator<Dynamic>() {
  @Override
  public int compare(Dynamic o1, Dynamic o2) {
   return o1.getTitle().compareTo(o2.getTitle());
  }
 });

which gives me the following exception.
IllegalAnnotationsException SetMultimap is an interface, and JAXB can't handle interfaces

My question is, how come this doesn't work but this does:
List<Dynamic> test = new ArrayList<Dynamic>();

And how can I fix the SetMultimap so that JAXB is happy?

A:

The difference between List/ArrayList and SetMultimap is that one is a Java collection, and the other is a data structure outside the normal Java collection hierarchy.  This means JAXB considers it a normal class.
The JAXB spec does not support interfaces.  You are probably using the Metro JAXB implementation which also does not support interfaces.  Some JAXB implementations such as MOXy can support interfaces, but some JAX-WS implementations depend upon a particular JAXB impl, and substituting JAXB implementations is not always possible:

http://bdoughan.blogspot.com/2010/07/moxy-jaxb-map-interfaces-to-xml.html
http://bdoughan.blogspot.com/2010/07/jaxb-xml-binding-standard.html

Your best bet is to use a parameter level annotation to convert SetMultimap to a class that can be handled by JAXB:

http://bdoughan.blogspot.com/2010/07/xmladapter-jaxbs-secret-weapon.html

