I encountered the same error with the same formulations, but this turned out to be a completely different problem than the dependency problem, for example, the proposed error. Therefore, I share my meeting here, in case someone there can also win.
There was something similar in my code:
public class ImageObject { @XmlElementWrapper(name="shapes") @XmlAnyElement(lax=true) @XmlElementRefs({ @XmlElementRef(name = "circle", type=Circle.class), @XmlElementRef(name = "square", type=Square.class), @XmlElementRef(name = "rectangle", type=Rectangle.class), @XmlElementRef(name = "triangle", type=Triangle.class) }) private List<Object> shapes; ... }
And in the Rectangle class, I had a typo in the element name specified for @XmlRootElement - "retangle" , not matching the name of the "rectangle" inside @XmlElementRef in the ImageObject class:
@XmlRootElement(name = "retangle") public class Rectangle extends Shape { @XmlAttribute private String colour; @XmlAttribute private String width; ... }
So, pay attention to this if you use the @XmlElementRef annotation.
source share