- This topic has 1 reply, 2 voices, and was last updated 17 years, 11 months ago by Haris Peco.
-
AuthorPosts
-
semajMemberHi 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.xmlI 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
Haris PecoMembersemaj,
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,
-
AuthorPosts