javax.el.ELException for property not found

2.3k Views Asked by At

I have the following html file:

<h:body>
    <h:form id="loginForm">
        <p:growl id="msg" showDetail="true" life="3000" />
        <p:panel header="Login" style="width: 360px;">
            <h:panelGrid id="loginPanel" columns="2">
                <h:outputText value="Username" />
                <p:inputText id="username" value="#{loginBean.uname}" ></p:inputText>
                <p:spacer></p:spacer>
                <p:message for="username" ></p:message>
                <h:outputText value="Password" />
                <p:password id="password" value="#{loginBean.password}"  feedback="false"></p:password>
                <p:spacer></p:spacer>
                <p:message for="password"></p:message>
                <p:spacer></p:spacer>
                <p:commandButton action="#{loginBean.loginPro}" value="Login" update="loginForm" ajax="true"></p:commandButton>
            </h:panelGrid>
        </p:panel>
    </h:form>
</h:body>

And the LoginBean is as follow:

@ManagedBean(name = "loginBean")
@SessionScoped
public class LoginBean implements Serializable {

    private static final long serialVersionUID = 1L;
    private String uname;
    private String password;


    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public String loginPro() {
        boolean result = false;
        try {
            result = UserDAO.login(uname, password);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if (result) {
            return "home";
        } else {
            FacesContext.getCurrentInstance().addMessage(
                    null,
                    new FacesMessage(FacesMessage.SEVERITY_WARN,
                            "Invalid Login!",
                            "Please Try Again!"));
            return "login";
        }
    }

I keep on receiving the following message eventhough loginPro method exists on LoginBean:

javax.servlet.ServletException: /index.xhtml: Property 'loginPro' not found on type beans.LoginBean javax.faces.webapp.FacesServlet.service(FacesServlet.java:659) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Any opinions?

2

There are 2 best solutions below

0
On

try loginBean.loginPro()

with loginBean.loginPro u said there is a property variable with get/set

0
On

I had the same issue and resolved adding below code snippet at the beginning

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

            <html xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">