I used following xml to configure my Hibernate SessionFactory:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
This works well, when the mapping files are in the filesystem, but if I pack my hibernate mapping files in a jar, I get the following exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [local-config.xml]: Initialization of bean failed; nested exception is java.io.FileNotFoundException: class path resource [mypackage/types] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/C:/myproject/myjar.jar!/mypackage/types
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapab
I was able to solve this problem by indicating every individual mapping file using the mappingResources property. However, this is quite cumbersome, since it requires the configuration file to be adapted every time I add, delete or rename a mapping file.
My question is whether there is a way to still use the mappingDirectoryLocation property when the files are packed in a jar?