JAXB Java Runtime Error with Getter but no Setter



I'm using the following class:



package com.mycom.ecnviewerview.viewer;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Report {

private String srunDate = null;
private String sUserID = null;
private List<Result> results = new ArrayList<Result>();

@XmlElement
public String getRunDate()
{
return this.srunDate;
}

public void setRunDate(String pRunDate)
{
this.srunDate = pRunDate;
}

@XmlElement
public String getUser()
{
return this.sUserID;
}

public void SetUser(String pUser)
{
this.sUserID = pUser;
}

@XmlElement
public List<Result> getResults()
{
return results;
}

public void SetResults(List<Result> pResults)
{
results = pResults;
}


}


And when I call the following code:



JAXBContext jaxbContext = JAXBContext.newInstance(Report.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();

jaxbUnmarshaller.setEventHandler(new ValidationEventHandler() {
public boolean handleEvent(ValidationEvent event ) {
throw new RuntimeException(event.getMessage(),
event.getLinkedException());
}
});

Report report = (Report) jaxbUnmarshaller.unmarshal(new FileReader("C:\\Temp\\File.xml"));

txtRunBy.setText(report.getUser());
txtRunDate.setText(report.getRunDate());
results = report.getResults();


The error is:


Err=java.lang.RuntimeException: The property has a getter "public java.lang.String com.mycom.ecnviewerview.viewer.Report.getUser()" but no setter. For unmarshalling, please define setters. (Or if this is a collection property, make sure that the getter returns a collection instance.)


I'm confused because I believe that I have a getter and a setter.


Any ideas?


Thanks, Kevin


No comments:

Post a Comment