0
votes

Im new with Spring, and Iam having this exception.

I have a jsp, with many selects. All of them work fine, but one show this exception:

org.apache.jasper.JasperException: Ha sucedido una excepción al procesar la página JSP /WEB-INF/pages/nuevo-expediente.jsp en línea 45

42:                     <td>
43:                         <form:select path="expedientePadre.codExpediente">
44:                             <form:option value="-" label="Seleccione un     expediente"/>
45:                             <form:options items="${expedientes}"    itemLabel="codExpediente" itemValue="codExpediente"/>
46:                         </form:select>
47:                         <form:errors path="expedientePadre" element="span"/>
48:                     </td>

org.springframework.beans.NotReadablePropertyException: Invalid property 'codExpediente' of bean class [com.atlantis.atecliente.model.TipoExpediente]: Bean property 'codExpediente' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

Im implementing the selct same way others which are working fine. Here the jsp code:

            <tr>
                <td>Expediente padre:</td>
                <td>
                    <form:select path="expedientePadre.codExpediente">
                        <form:option value="-" label="Seleccione un expediente"/>
                        <form:options items="${expedientes}" itemLabel="codExpediente" itemValue="codExpediente"/>
                    </form:select>
                    <form:errors path="expedientePadre" element="span"/>
                </td>
            </tr>   

Here the controller:

@RequestMapping(value = "nuevo-expediente")
public String createExpedienteGet(Model model) {
    model.addAttribute("expediente", new Expediente());
    model.addAttribute("expedienteP", new Expediente());
    List<TipoResolucion> resoluciones = service.getResoluciones();
    List<TipoExpediente> listaTipos = service.getTipos();
    List<EstadoExpediente> listaEstados = service.getEstados();
    List<Expediente> listaExpedientes = service.getExpedientes();
    List<TipoRelacion> listaRelaciones = service.getRelaciones();
    List<CanalExpediente> listaCanales = service.getCanales();
    List<IdiomaExpediente> listaIdiomas = service.getIdiomas();
    model.addAttribute("resoluciones", resoluciones);
    model.addAttribute("tipos", listaTipos);
    model.addAttribute("estados", listaEstados);
    model.addAttribute("expedientes", listaExpedientes);
    model.addAttribute("tiposRelacion", listaRelaciones);
    model.addAttribute("canales", listaCanales);
    model.addAttribute("idiomas", listaIdiomas);
    return "nuevo-expediente";
}

@RequestMapping(value = "nuevo-expediente", method = RequestMethod.POST)
public String createExpedientePost(@ModelAttribute("expediente") Expediente expediente, BindingResult result) {
    service.createExpediente(expediente);
    return "redirect:expedientes";
}

here, the entity Expediente:

@Entity
@Table(name="Expediente")
public class Expediente implements Serializable {
@Id
@Column(length = 15)
private String codExpediente;

@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "tipoExpediente")
private TipoExpediente tipoExpediente;

@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "estadoExpediente")
private EstadoExpediente estadoExpediente;

@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "expedientePadre")
private Expediente expedientePadre;

@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "tipoRelacion")
private TipoRelacion tipoRelacion;

@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "canalEntrada")
private CanalExpediente canalEntrada;

@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "idiomaEntrada")
private IdiomaExpediente idiomaEntrada;

@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "idiomaSalida")
private IdiomaExpediente idiomaSalida;

@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "tipoResolucion")
private TipoResolucion tipoResolucion;

@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "canalSalida")
private CanalExpediente canalSalida;

@Column(length = 10)
private String numeroSerie;

@Column(length = 10)
private String numeroHoja;

@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaRedaccion;

@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaRecepcion;

@Column(length = 200)
private String asunto;

@Column (length = 1000)
private String descripcion;

@Column(length = 20)
private String usuarioRegistro;

@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaRegistro;

@Column (length = 20)
private String usuarioModificacion;

@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaModificacion;

@Column (length = 20)
private String usuarioCierre;

@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaCierre;

public String getCodExpediente() {
    return codExpediente;
}

public void setCodExpediente(String codExpediente) {
    this.codExpediente = codExpediente;
}

............................
............................

And finally the TipoExpediente Entity

package com.atlantis.atecliente.model;

import java.io.Serializable;
import javax.persistence.*;

@Entity
@Table
public class TipoExpediente implements Serializable {
@Id
@Column(length = 40)
private String tipo;

public String getTipo() {
    return tipo;
}

public void setTipo(String tipo) {
    this.tipo = tipo;
}
}

I think it could happen because the expedientePadre property, is a foreign key to the same entity Expediente, but I dont know resolve it...

Some help? Thanks!

1
Show us your TipoExpediente class. - Sotirios Delimanolis
I have added the class. Thanks - alberph

1 Answers

0
votes

I think the problem is that your class TipExpediente class does not have getter or setter methods for the property codExpedient. Spring is looking at your TipoExpediente class and expecting it to have the property you outlined in the JSP.