This is killing me, I've been following the code examples found at
https://jaxb.dev.java.net/guide/Mapping_interfaces.html regarding techniques
to use with JAXB to allow the usage of interfaces/abstract classes with JAXB
marshalling/unmarshalling.
I can get this to work with straight marshall/unmarshall calls, however when
I try to use it with a JAX-RS Jersey service like the following:
@PUT
@ConsumeMime({ "application/xml", "java/object" })
@ProduceMime({ "application/xml", "java/object" })
public void sendNew(final ConduitDemand demand) {
if (LOG.isDebugEnabled()) {
LOG.debug("Got Demand [" + demand + "]");
}
}
Where ConduitDemand is an interface, AbstractConduitDemandBase is an
abstract base impl, and ConduitDemand1 is an actual impl class. No matter
what combination I try, I can never have any success unless I relegate to
directly using the impl class ConduitDemand1 as the arg in the JAX-RS
resource.
I've tried creating an XmlAdapter class on each of the
AbstractConduitDemandBase and ConduitDemand1 classes, either with one or the
other, or both.. and every combination I can think of, but I always get one
of the following errors:
- ConduitDemand is an interface, and JAXB can't handle interfaces.
- A message body reader for Java type, interface ConduitDemand, and MIME
media type, application/xml, was not found
I've also gotten the same error for ConduitDemand1 (this was resolved by
adding an @XmlRootElement(name="demand") annotation to the empty
ConduitDemand1 class, which extends the Abstract class which has the same
@XmlRootElement(name="demand") annotation on it
Anyone know of a way I can use an interface in the JAX-RS service resources?
Alex Sherwin
alex.sherwin_at_acadiasoft.com