Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I'm using XMLMapper to deserialize AIML code (mostly the same as XML) and got this problem when I mix text and tags under the same tag. Example:
<set name="setVar">
<srai>FUNCTION1</srai>
<srai>FUNCTION2<star index="1"/></srai>
My java classes definition are:
@JacksonXmlRootElement(localName = "set")
public class Set {
@JacksonXmlProperty(isAttribute = true, localName = "name")
public String name;
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty(localName = "srai")
public List<Srai> srais;
public Set() {
public Set(String name, List<Srai> srais) {
this.name = name;
this.srais = srais;
public String getName() {
return name;
public void setName(String name) {
this.name = name;
public List<Srai> getSrais() {
return srais;
public void setSrais(List<Srai> srais) {
this.srais = srais;
@JacksonXmlRootElement(localName = "srai")
public class Srai {
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty(localName = "star")
public List<Star> stars;
@JacksonXmlText
public String text;
public Srai() {}
public Srai(String text, List<Star> stars) {
this.text = text;
this.stars = stars;
public String getText() {
return text;
public void setText(String text) {
this.text = text;
public List<Star> getStars() {
return stars;
public void setStars(List<Star> stars) {
this.stars = stars;
@JacksonXmlRootElement(localName = "star")
public class Star {
@JacksonXmlProperty(isAttribute = true)
public int index;
public Star() {
public int getIndex() {
return index;
public void setIndex(int index) {
this.index = index;
If I try to deserialize code in which there are only text or only stars into the srai, everything works perfect, the problem appears when I mix text and tags.
I finally managed to solve it upgrading my jackson-databind, jackson-core, jackson-annotation and jackson-dataformat-xml to the version 2.12.1 as tnci suggested here.
To do this, just change their version into the pom.xml to 2.12.1 or later versions.
Then I created a new property into the star class:
@JacksonXmlText
public String text;
This way, when there is text before or between xml tags, it will be saved in this property on a star object. If the text is after all xml tags, there will appear this problem:
Unexpected end-of-input when trying read value of type `**root-agent-class**`
So the problem persists but now it's much better since we can read some text+tags code.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.