Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
semaj
Post subject: hibernate.cfg.xml  PostPosted: Nov 10, 2006 - 07:10 PM



Joined: Nov 10, 2006
Posts: 1

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
 
 View user's profile Send private message  
Reply with quote Back to top
support-snpe
Post subject:   PostPosted: Nov 11, 2006 - 03:07 PM
Moderator
Moderator


Joined: Feb 03, 2006
Posts: 1117

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,

_________________
Peco
MyEclipse Support
Please do us a big favor and remember to vote for MyEclipse at the JDJ Reader's Choice Awards.
We really appreciate it!
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits