This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
As I can see in your hbm.cfg.xml, you have used <mapping class="db_interaction.utilizador"></mapping> tag. This leads me to believe that you are using annotations in the class file to map it with corresponding table. When we use annotations to map class to table we use AnnotationConfiguration() not the Configuration() which is ment to be used when mapping is defined in hbm files.
Below code seciton is completely correct and does not need to be changed-
The code secion that you have pasted seems to be correct. I think the problem might be in mapping of utilizador which is preveting the session factory creation.
You are facing issues while debugging because you did not follow the best practices of exception handelling. Exception should be caught only if you can handle it else we should let it pass through. In HibernateUtil you are eating the exception and printing only the abstact of error message which is of not much use.
Considering the fact that buildSessionFactory does not throw any checked excption and we are not even handling un-checked exception, I do not see any reason why you have inclosed session factory creation in try catch block. Please remove it as mentioned in below code section, then you will get the complete trace, which will help you identifying the root cause of error.
If you still face any issues, please post the complete error trace in this forum.
Actually You got NullPointerException in the initial ocde due to duplicate variable declaration in the try block.
once the static block execution completes, those variables are no more.. hence the static variables remained NULL.