javax.el.PropertyNotFoundException !

Status
Nicht offen für weitere Antworten.

nimo22

Aktives Mitglied
Hallo,

woran kann das liegen, wenn ich folgende Fehlermeldung bekomme:


Code:
javax.el.PropertyNotFoundException: The class 'org.apache.catalina.core.ApplicationContextFacade' does not have the property 'applications'.

In "faces_config.xml" wurden alle Klassen mit Converter ordnungsgemäß eingebunden. In einer ManagedBean habe ich "applications" definiert und kann diese auch im JSF-Tag auswählen.

Rat?
 
M

maki

Gast
Hast du eine public Methode namens getApplications in der Bean?
 

nimo22

Aktives Mitglied
also die Entity-Bean heißt "Application" mit folgendem Inhalt:

Code:
@Entity
@Table(name = "APPLICATION")
@NamedQueries({@NamedQuery(name = "Application.findByIdApplication", query = "SELECT a FROM Application a WHERE a.idApplication = :idApplication"), })

public class Application implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ID_APPLICATION", nullable = false)
    private Integer idApplication;
    @Column(name = "APPNAME", nullable = false)
    private String appname;

    public Application() {
    }

    public Application(Integer idApplication) {
        this.idApplication = idApplication;
    }

    public Application(Integer idApplication, String appname) {
        this.idApplication = idApplication;
        this.appname = appname;
    }

    public Integer getIdApplication() {
        return idApplication;
    }

    public void setIdApplication(Integer idApplication) {
        this.idApplication = idApplication;
    }

    public String getAppname() {
        return appname;
    }

    public void setAppname(String appname) {
        this.appname = appname;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idApplication != null ? idApplication.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Application)) {
            return false;
        }
        Application other = (Application) object;
        if ((this.idApplication == null && other.idApplication != null) || (this.idApplication != null && !this.idApplication.equals(other.idApplication))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Application[idApplication=" + idApplication + "]";
    }

}

Im ControllerBean hab ich dann die "getApplication":

Code:
  public class ApplicationController {

    public ApplicationController() {
    }
    ...
    private Application application;

   public Application getApplication() {
    return application;
    }

    public void setApplication(Application application) {
        this.application = application;
...
    }

Wenn ich die JSF erstelle, erscheint bei Eingabe von z.B.

Code:
<h:dataTable value='#{application.applications}' var='item' border="1" cellpadding="2" cellspacing="0">
ein DropDown-Menu, wenn ich "application." eingebe. In dem Drop-Down-Menu kann ich dann "applications" auswählen.

Rat?[/code]
 
M

maki

Gast
Mehr lesen.

Schreibe eine getApplications Methode in deiner Bean und lasse sie etwas sinnvolles zurückgeben.

Deine equals Methode ist nicht so toll, ids sollte man nicht verwenden, bekommst Probleme wenn die transiente Objekte auseinander halten willst.
Es gibt einen Unterschied zwischen Gleichheit und Identität ;)
 

nimo22

Aktives Mitglied
Jetzt bekomm ich folgende Fehlermeldung:

Code:
java.lang.RuntimeException: Cannot find FacesContext
 
R

Rodge

Gast
Der Fehler erscheint erst, seit ich folgenden Pointcut definiert habe:

<aop:pointcut id="shopControllerMethods"
expression="execution(* ch.xxx.yyy.gui.controller.*.*(..))" />

<aop:aspect ref="errorPageAspect">
<aop:around pointcut-ref="shopControllerMethods"
method="showErrorPage" />
</aop:aspect>

<aop:aspect ref="exceptionAlerterAspect">
<aop:around pointcut-ref="shopControllerMethods"
method="sendExceptionAlert" />
</aop:aspect>

<aop:aspect ref="loggingAspect">
<aop:around pointcut-ref="shopControllerMethods"
method="logCallWithException" />
</aop:aspect>

hat da wer ne idee, was da die Ursacleh sein könnte?
 

TurionDanae

Neues Mitglied
Ich arbeite momentan ebenfalls an einem Java EE Projekt und verwende dabei den JBoss AS, Seam und MySQL zusammen mit Eclipse Galileo und den JBoss Tools für Eclipse. Ich hatte ein Facelet das mir stundenlang eine ähnliche Fehlermeldung ausgab:

Java:
javax.el.PropertyNotFoundException: /application.xhtml @22,111 value="#{application.university}": Property 'university' not found on type org.apache.catalina.core.ApplicationContextFacade

Die Entity Bean hat definitiv eine entsprechende get- und set-Methode, zudem kam der Fehler auch wenn ich eines der anderen Attribute der Bean einzeln (!) im Facelet mittels Expression Language testete. Die Bean Klasse heisst dabei "Application.java" und bekommt durch die @Name Annotation den Namen "application". Converter kommen bei mir ebenfalls zum Einsatz, sind aber nicht das Problem und funktionieren an anderer Stelle einwandfrei. Lange Rede kurzer Sinn:

Ich hab diesen Post letztlich nur gefunden, weil meine Entity mit @Name("application") annotiert ist. Also habe ich sie in @Name("irgendwasApplication") geändert und der Fehler war sofort weg. Es scheint sich also um reservierte Namen zu handeln, wovon ich bisher in dem Zusammenhang noch überhaupt nichts gehört habe. Selbst wenn es irgendwo dokumentiert ist, finde ich das unmöglich. In jedem Fall sollte man wenigstens eine aussagekräftige Fehlermeldung erhalten, propertyNotFound ist total daneben.

Grüße
T.
 
Zuletzt bearbeitet:
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen

Ähnliche Java Themen

Neue Themen


Oben