获取json jax rs时出错

获取json jax rs时出错,json,jersey,jax-rs,Json,Jersey,Jax Rs,这是我与邮递员重新请求时从服务器获得的信息: { "NBanios": 5, "NHabitaciones": 4, "antiguedad": "asd", "anuncioInmueble": { "cp": "31927", "descripcion": "la casa falete", "direccion": "pocillogilvan", "idInmueble": 1,

这是我与邮递员重新请求时从服务器获得的信息:

{
    "NBanios": 5,
    "NHabitaciones": 4,
    "antiguedad": "asd",
    "anuncioInmueble": {
        "cp": "31927",
        "descripcion": "la casa falete",
        "direccion": "pocillogilvan",
        "idInmueble": 1,
        "latitud": -7.12367,
        "longitud": 41.36360142022258,
        "numero": "2",
        "planta": "3",
        "precio": 13.4,
        "superficie": 5000,
        "tipoAnuncio": "venta"
    },
    "certificado": 3,
    "conservacion": "asd",
    "idInmueble": 1,
    "orientacion": "asd",
    "tipoVivienda": "asd"
}
波乔

这是我调用的方法(使用向导(netbeans)构建):


谢谢。

奇怪的是,如果你没有提供程序,它不会在服务器端给你错误。你能显示你的依赖关系吗。还要尝试添加。我必须在客户端或服务器端添加ObjectMapperProvider?你能帮我在没有maven的情况下添加它吗?谢谢!@peeskillet我想他还必须在Vivienda类中添加注释。
@XmlRootElement
    @XmlAccessorType(XmlAccessType.PROPERTY)
    public class AnuncioInmueble  implements java.io.Serializable {


         private Integer idInmueble;
         private Municipios municipios;
         private Usuario usuario;
         private String tipoAnuncio;
         private String direccion;
         private String cp;
         private String numero;
         private String planta;
         private int superficie;
         private double precio;
         private String descripcion;
         private double longitud;
         private double latitud;
         private Oficina oficina;
         private Vivienda vivienda;
         private Garaje garaje;
         private Set opinions = new HashSet(0);
         private Set favoritos = new HashSet(0);
         private Set fotos = new HashSet(0);

        public AnuncioInmueble() {
        }


        public AnuncioInmueble(Municipios municipios, Usuario usuario, String tipoAnuncio, String direccion, String cp, String numero, String planta, int superficie, double precio, String descripcion, double longitud, double latitud) {
            this.municipios = municipios;
            this.usuario = usuario;
            this.tipoAnuncio = tipoAnuncio;
            this.direccion = direccion;
            this.cp = cp;
            this.numero = numero;
            this.planta = planta;
            this.superficie = superficie;
            this.precio = precio;
            this.descripcion = descripcion;
            this.longitud = longitud;
            this.latitud = latitud;
        }
        public AnuncioInmueble(Municipios municipios, Usuario usuario, String tipoAnuncio, String direccion, String cp, String numero, String planta, int superficie, double precio, String descripcion, double longitud, double latitud, Oficina oficina, Vivienda vivienda, Garaje garaje, Set opinions, Set favoritos, Set fotos) {
           this.municipios = municipios;
           this.usuario = usuario;
           this.tipoAnuncio = tipoAnuncio;
           this.direccion = direccion;
           this.cp = cp;
           this.numero = numero;
           this.planta = planta;
           this.superficie = superficie;
           this.precio = precio;
           this.descripcion = descripcion;
           this.longitud = longitud;
           this.latitud = latitud;
           this.oficina = oficina;
           this.vivienda = vivienda;
           this.garaje = garaje;
           this.opinions = opinions;
           this.favoritos = favoritos;
           this.fotos = fotos;
        }

        public Integer getIdInmueble() {
            return this.idInmueble;
        }

        public void setIdInmueble(Integer idInmueble) {
            this.idInmueble = idInmueble;
        }
        @XmlTransient
        public Municipios getMunicipios() {
            return this.municipios;
        }

        public void setMunicipios(Municipios municipios) {
            this.municipios = municipios;
        }
        @XmlTransient
        public Usuario getUsuario() {
            return this.usuario;
        }

        public void setUsuario(Usuario usuario) {
            this.usuario = usuario;
        }
        public String getTipoAnuncio() {
            return this.tipoAnuncio;
        }

        public void setTipoAnuncio(String tipoAnuncio) {
            this.tipoAnuncio = tipoAnuncio;
        }
        public String getDireccion() {
            return this.direccion;
        }

        public void setDireccion(String direccion) {
            this.direccion = direccion;
        }
        public String getCp() {
            return this.cp;
        }

        public void setCp(String cp) {
            this.cp = cp;
        }
        public String getNumero() {
            return this.numero;
        }

        public void setNumero(String numero) {
            this.numero = numero;
        }
        public String getPlanta() {
            return this.planta;
        }

        public void setPlanta(String planta) {
            this.planta = planta;
        }
        public int getSuperficie() {
            return this.superficie;
        }

        public void setSuperficie(int superficie) {
            this.superficie = superficie;
        }
        public double getPrecio() {
            return this.precio;
        }

        public void setPrecio(double precio) {
            this.precio = precio;
        }
        public String getDescripcion() {
            return this.descripcion;
        }

        public void setDescripcion(String descripcion) {
            this.descripcion = descripcion;
        }
        public double getLongitud() {
            return this.longitud;
        }

        public void setLongitud(double longitud) {
            this.longitud = longitud;
        }
        public double getLatitud() {
            return this.latitud;
        }

        public void setLatitud(double latitud) {
            this.latitud = latitud;
        }
        @XmlTransient
        public Oficina getOficina() {
            return this.oficina;
        }

        public void setOficina(Oficina oficina) {
            this.oficina = oficina;
        }
        @XmlTransient
        public Vivienda getVivienda() {
            return this.vivienda;
        }

        public void setVivienda(Vivienda vivienda) {
            this.vivienda = vivienda;
        }
        @XmlTransient
        public Garaje getGaraje() {
            return this.garaje;
        }

        public void setGaraje(Garaje garaje) {
            this.garaje = garaje;
        }
        @XmlTransient
        public Set getOpinions() {
            return this.opinions;
        }

        public void setOpinions(Set opinions) {
            this.opinions = opinions;
        }
        @XmlTransient
        public Set getFavoritos() {
            return this.favoritos;
        }

        public void setFavoritos(Set favoritos) {
            this.favoritos = favoritos;
        }
        @XmlTransient
        public Set getFotos() {
            return this.fotos;
        }

        public void setFotos(Set fotos) {
            this.fotos = fotos;
        }

 public class Vivienda  implements java.io.Serializable {
         private int idInmueble;
         private AnuncioInmueble anuncioInmueble;
         private String tipoVivienda;
         private int NHabitaciones;
         private int NBanios;
         private String conservacion;
         private String antiguedad;
         private String orientacion;
         private int certificado;

        public Vivienda() {
        }

        public Vivienda(AnuncioInmueble anuncioInmueble, String tipoVivienda, int NHabitaciones, int NBanios, String conservacion, String antiguedad, String orientacion, int certificado) {
           this.anuncioInmueble = anuncioInmueble;
           this.tipoVivienda = tipoVivienda;
           this.NHabitaciones = NHabitaciones;
           this.NBanios = NBanios;
           this.conservacion = conservacion;
           this.antiguedad = antiguedad;
           this.orientacion = orientacion;
           this.certificado = certificado;
        }

        public int getIdInmueble() {
            return this.idInmueble;
        }

        public void setIdInmueble(int idInmueble) {
            this.idInmueble = idInmueble;
        }
        public AnuncioInmueble getAnuncioInmueble() {
            return this.anuncioInmueble;
        }

        public void setAnuncioInmueble(AnuncioInmueble anuncioInmueble) {
            this.anuncioInmueble = anuncioInmueble;
        }
        public String getTipoVivienda() {
            return this.tipoVivienda;
        }

        public void setTipoVivienda(String tipoVivienda) {
            this.tipoVivienda = tipoVivienda;
        }
        public int getNHabitaciones() {
            return this.NHabitaciones;
        }

        public void setNHabitaciones(int NHabitaciones) {
            this.NHabitaciones = NHabitaciones;
        }
        public int getNBanios() {
            return this.NBanios;
        }

        public void setNBanios(int NBanios) {
            this.NBanios = NBanios;
        }
        public String getConservacion() {
            return this.conservacion;
        }

        public void setConservacion(String conservacion) {
            this.conservacion = conservacion;
        }
        public String getAntiguedad() {
            return this.antiguedad;
        }

        public void setAntiguedad(String antiguedad) {
            this.antiguedad = antiguedad;
        }
        public String getOrientacion() {
            return this.orientacion;
        }

        public void setOrientacion(String orientacion) {
            this.orientacion = orientacion;
        }
        public int getCertificado() {
            return this.certificado;
        }

        public void setCertificado(int certificado) {
            this.certificado = certificado;
        }
Vivienda vivienda = getById(Vivienda.class,"2");


 public <T> T getById(Class<T> responseType, String id) throws ClientErrorException {
        WebTarget resource = webTarget;
        if (id != null) {
            resource = resource.queryParam("id", id);
        }
        resource = resource.path("byId");
        return resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=application/json, type=class hibernate.entidades.Vivienda, genericType=class hibernate.entidades.Vivienda.
    org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:173)
    org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:134)
    org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:988)
    org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:833)
    org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:768)
    org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:96)
    org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:740)
    org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:88)
    org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:650)
    org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    org.glassfish.jersey.internal.Errors.process(Errors.java:228)
    org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:421)
    org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:646)
    org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:375)
    org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:275)
    ws.ViviendaREST.getById(ViviendaREST.java:41)
    actions.detail_vivienda.execute(detail_vivienda.java:50)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)