You've got an annotation conflict with your top-level class name and the name placed on the Level
class.
You've annotated your Level
class with the XmlElementRoot set to "Levels", which is actually the root element for your Levels
class. Since you didn't specify it explicitly in your annotation for that class, the JAXB binding is returning a different mapping for your classes.
I created a quick mockup of your program, and was able to get it working properly with the following:
Levels class:
@XmlRootElement(name="Levels")
public class Levels {
private List<Level> levels = new ArrayList<Level>();
@XmlElementRef(name="Level")
public List<Level> getLevels() {
return levels;
}
public void setLevels(List<Level> levels) {
this.levels = levels;
}
}
Level class:
@XmlRootElement(name="Level")
public class Level {
private Solution solution = new Solution();
private Clues clues = new Clues();
@XmlElementRef(name="Solution")
public Solution getSolution() {
return solution;
}
public void setSolution(Solution solution) {
this.solution = solution;
}
@XmlElementRef(name="Clues")
public Clues getClues() {
return clues;
}
public void setClues(Clues clues) {
this.clues = clues;
}
}
Clues class (empty because I just needed a class definition):
@XmlRootElement
public class Clues {
}
Solution class (same as above):
@XmlRootElement
public class Solution {
}
Running the code using your input produces:
Levels@***