As you can see I have a HibernateUtil that I use to persist data to my database. The same code I use in my userBean.save method is the same code I use in my
junit test. In my junit test below it works perfectly. However when I try to call the userBean.save method in my commandbutton it gives me an error, org.hibernate.HibernateException: /hibernate.cfg.xml not found.
After some debugging I can tell you the error happens in hibernateUtil class, configuration.configure().addAnnotatedClass(userBean.class);
If I change the commandbutton action to welcome, which is the name of my welcome page, the form works fine by redirecting me to the welcome page and it outputs the bean values on the page. This means , as far as I'm concerned ,that the bean is been initialized correctly. This is very confusing, why is it working in my junit test and not on my
jsf page?
Bean class
Junit test
index.xhtml
As I said the problem is comming from configuration.configure().addAnnotatedClass(userBean.class);
So I took my debugger through and copied the console outputs from when we cross this piece of code. Here is the output from the working Junit test
Here is the code from the not working jsf running
Here is an image of my folder structure showing my src and deployed resources as well