views:

105

answers:

1

I get the following error when I run my java ee app on weblogic,

javax.servlet.jsp.el.ELException: Cannot find PropertyDescriptor for 'name' for bean 'class java.lang.String'

I want to print a list of artists with the following class,

    public class Artist {
    private int id; 
    private String name;
    private String genre;

    public Artist() {

    }
    public Artist(String name){
        this.name=name;
    }
    public void setId(int id) {
        this.id = id;
    }   
    public int getId() {
        return id;
    }
     public void setName(String name) {
        this.name = name;
    }
     public String getName() {
        return name;
    }
     public String getGenre() {
        return genre;
    }
     public void setGenre(String genre) {
        this.genre = genre;
    }
}

The following lines of code seem to be causing the problem because when I remove it I don't get the error anymore.

<c:forEach items="artists" var="artist">
    <c:out value="${artist.name}"></c:out><br/>
</c:forEach>

When I use PrintWriter to print, it works:

for (Artist artist:artists){
    resp.getWriter().println(artist.getName());
}

I am using java ee 2.4 and weblogic 9.2

+1  A: 

Take a look at the value of the items attribute of the <c:forEach> tag - it's a string literal, not an EL expression. In other words, this should work:

<c:forEach items="${artists}" var="artist">
    <c:out value="${artist.name}"></c:out><br/>
</c:forEach>
kschneid