I have some hbm.xml files in classpath resource located in src/main/resources maven\'s folder. I used spring\'s LocalSessionFactoryBean to load these files with the followin
If you are loading your Spring application context from a webapp, you might see an error like this:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: ServletContext resource [/hibernate.cfg.xml] cannot be resolved to URL because it does not exist
The solution is to explicitly tell Spring to load the configuration from the classpath like so:
classpath:mypath/myfile.xml