I'm trying to show data from mysql database in JSF, but getting error:

javax.servlet.ServletException: /index.xhtml @16,70 value="#{userBean.getUserList()}": The class 'com.dev.UserBean' does not have the property 'getUserList'.
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)

I'm using http://www.devmanuals.com/tutorials/java/jsf/database/viewdata.html tutorial

UserBean.java

package com.dev;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import com.dev.user.model.User;

@ManagedBean(name = "userBean")
@SessionScoped
public class UserBean {

    public List<User> getUserList()
    {
        List<User> list = new ArrayList<User>();
        PreparedStatement ps = null;
        Connection con = null;
        ResultSet rs = null;
        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "root", "");
            String sql = "select * from user1";
            ps= con.prepareStatement(sql);      
            rs= ps.executeQuery();          
            while (rs.next())
            {
                User usr = new User();
                usr.setUserID(rs.getLong("userId"));
                usr.setName(rs.getString("name"));
                usr.setAddress(rs.getString("address"));
                usr.setCreated_date(rs.getDate("created_date"));
                list.add(usr);
            }       
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            try
            {
            con.close();
            ps.close();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
        return list;
    }
}

User.java

package com.dev.user.model;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import java.util.Date;

@ManagedBean(name="user")
@RequestScoped
public class User {

    private long userID;
    private String name;
    private String address;
    private Date created_date;
    public long getUserID() {
        return userID;
    }
    public void setUserID(long userID) {
        this.userID = userID;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public Date getCreated_date() {
        return created_date;
    }
    public void setCreated_date(Date created_date) {
        this.created_date = created_date;
    }   
}

index.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      >
    <h:head>
        <title>index.xhtml</title>
    </h:head>

    <h:body>

        <h1>JSF 2.0 View Data From The Database Table Example</h1>

        <h:dataTable value="#{userBean.getUserList()}" var="u" border="1">

            <h:column>
                <f:facet name="header">
                    User ID
                </f:facet>
                    #{u.userID}
            </h:column>

            <h:column>
                <f:facet name="header">
                    Name
                </f:facet>
                    #{u.name}
            </h:column>

            <h:column>
                <f:facet name="header">
                    Address
                </f:facet>
                    #{u.address}
            </h:column>

            <h:column>
                <f:facet name="header">
                    Created Date
                </f:facet>
                    #{u.created_date}
            </h:column>

        </h:dataTable>

    </h:body>

</html>

Please help

if I'm not mistaken, you're not supposed to use the 'get' when you call the getter.
try to do it the way it is suggested here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.