I am working on a Java EE project, and I had deployed my Rest Webservices using Jackson . the services works fine but one problem I have is that I don't get the root name :
here's an example of :
[{"idRegion":1,"intituleRegion":"Sous Massa Draa"},
{"idRegion":2,"intituleRegion":"Chawya W rdigha"},{"idRegion":3,"intituleRegion":"rabat sale zemmour zaer"},
{"idRegion":4,"intituleRegion":"grand casablanca "},
{"idRegion":5,"intituleRegion":"marrakech tansift lhawz"},{"idRegion":6,"intituleRegion":"essaouira"},
{"idRegion":7,"intituleRegion":"fes boulemane "}]
knowing that I had define the : @XmlRootElement(name="region")
JAXB BEAN :
package ma.propar.FireApp.Entites;
@Entity
@Table (name = "REGION")
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name="region")
public class Region {
@Id @GeneratedValue
@Column( name = "ID_REGION" )
@XmlElement
private int idRegion;
@Column( name = "INTITULE_REGION" )
@XmlElement
private String intituleRegion;
@OneToMany ( targetEntity = Zone.class, cascade=CascadeType.ALL ,mappedBy="region")
private List<Zone> zones;
@WebMethod(exclude=true)
public List<Zone> getZones() {
return zones;
}
@WebMethod(exclude=true)
public void setZones(List<Zone> zones) {
this.zones = zones;
}
public Region() {
}
public int getIdRegion() {
return idRegion;
}
public void setIdRegion(int idRegion) {
this.idRegion = idRegion;
}
public String getIntituleRegion() {
return intituleRegion;
}
public void setIntituleRegion(String intituleRegion) {
this.intituleRegion = intituleRegion;
}
/*@WebMethod(exclude=true)
public List<Zone> getZones() {
return zones;
}
@WebMethod(exclude=true)
public void setZones(List<Zone> zones) {
this.zones = zones;
}*/
}
Jackson with jax-rs :
<jaxrs:server id="regionservices" address="/regionservices">
<jaxrs:serviceBeans>
<ref bean="regionMetier" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" />
</jaxrs:providers>
<jaxrs:extensionMappings>
<entry key="json" value="application/json" />
</jaxrs:extensionMappings>
</jaxrs:server>
any body can help ?