The below is my JAXB Binding class which i am using during JAXB Unmarshalling process .
package com;
@XmlRootElement(name = "request")
@XmlAccessorType(XmlAccessType.FIELD)
public class CustAcct {
@XmlAttribute
private String cust;
@XmlAttribute
private String acct;
public CustAcct() {
super();
}
public String getCust() {
return cust;
}
public void setCust(String s) {
cust = s;
}
public String getAcct() {
return acct;
}
public void setAcct(String s) {
acct = s;
}
}
Now my question is that , i am unable to include the annotation @Context ServletContext inside the above class .
public class CustAcct {
@XmlAttribute
private String cust;
@XmlAttribute
private String acct;
@Context
ServletContext cont ;
I am getting the Exception , with this Message
javax.servlet.servletcontext is an interface and jaxb can't handle interfaces
Please let me know if is it possible to have the inbuilt ServletContext Annotation inside the JAXB Binding class ??
Thanks in advance .
I tried this way ,
@XmlRootElement(name = "request")
@XmlAccessorType(XmlAccessType.FIELD)
public class CustAcct {
@XmlAttribute
private String acct;
@XmlTransient
@Context
ServletContext con;
public CustAcct() {
super();
}
public String getAcct() {
return acct;
}
public void setAcct(String s) {
acct = s;
}
}
But i am getting the following Exception when i am trying to access it inside a Jersey Service
SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
java.lang.NullPointerException
You can annotate that field with @XmlTransient
. This prevents your JAXB (JSR-222) implementation from treating it as mapped data.
For More Information