I have never used JAXB before. I am working on a test harness project. I have about 20 different test cases. When I run my test, I get this error.
My structure is similar:
A is the base class of TestCase.
Bthe extends A.
Cthe extends B.
Base Class A:
public class A {
public A(String t){
testName = t;
}
private String aData;
private String testName;
public void setAData(String a){
aData = a;
}
public void getAData(){
return aData;
}
public void setTestName(String t){
testName = t;
}
public void getTestName(){
return testName;
}
}
Grade B:
public class B extends A{
public B(String testName){
super(testName);
}
private String bData;
public void setBData(String b){
bData = b.trim();
}
public String getData(){
return bData;
}
}
Grade C:
@XmlRootElement(name="C")
public class C extends B{
public C(String testName){
super(testName);
}
private String cData;
public void setCData(String c){
cData = c;
}
public String getCData(){
return cData;
}
}
and for unmarshalling my xml files that I wrote
public C unmarshall(C test, String dir){
try {
JAXBContext jc = JAXBContext.newInstance(c.getClass);
Unmarshaller u = jc.createUnmarshaller();
test = (C)u.unmarshal(new FileInputStream(dir));
} catch (Exception e) {
System.out.println(e.getMessage());
}
return test;
}
my xml file looks like this:
<C>
<aData> aaaa </aData>
<bData> bbbb </bData>
<cData> cccc </cData>
</C>
when I run my code, I get 3 IllegalAnnotationException exception accounts.
source
share