facebook

hibernate.cfg.xml

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #261597 Reply

    semaj
    Member

    Hi there,

    I create a Hibernate project as described in the Hibernate QuickStart tutorial. It works fine.
    When I ran the wizard, it created the following files as described in tutorial:
    Under com.nepatalk.hibernate package
    AbstractUsers.java
    BaseHibernateDAO.java
    HibernateSessionFactory.java
    IBaseHibernateDAO.java
    Users.java
    UsersDAO.java
    Users.hbm.xml

    I have Users table in mySQL database.

    The wizard created hibernate.cfg.xml in src folder. In the quickstart tutorial, it showed that the file is created under com.nepatalk.hibernate package.
    Anyway, I created UsersClient.java and tested the application. It works fine. I created a session bean named LoginBean in order to validate if the username and password is correct. I have the following authenticate() to check if the username and password is valid.

    public boolean authenticate(String username, String password) throws EJBException {

    boolean isAuthenticated = false;
    UsersDAO usersDAO = null;
    try {
    usersDAO = new UsersDAO();

    Users users = usersDAO.findById(username);

    if (users != null && users.getPassword().equals(password) )
    isAuthenticated = true;
    } catch (HibernateException ex)
    {
    ex.printStackTrace();
    }
    finally {
    usersDAO.getSession().close();
    }

    return isAuthenticated;
    }

    When I run the application, I get org.hibernate.HibernateException: /hibernate.cfg.xml not found exception.

    Does anyone have any idea? I have CONFIG_FILE_LOCATION = “/hibernate.cfg.xml” in HibernationSessionFactory class. I think this is correct, but I don’t know why it keeps on saying /hibernate.cfg.xml not found.

    Any help would be greatly appreciated.

    Thank you,
    semaj

    #261606 Reply

    Haris Peco
    Member

    semaj,

    If your hibernate.cfg.xml is in src folder, and HibernateSessionFactory contains CONFIG_FILE_LOCATION = “/hibernate.cfg.xml”, then your src folder is not in source folder.Check that it is in source folder with Project properties>Build Path

    Regards,

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: hibernate.cfg.xml

You must be logged in to post in the forum log in