-
Oct 22nd, 2007, 09:59 AM
#1
org.springframework.orm.hibernate3.HibernateSystem Exception: Unknown entity
Hi All,
I have just started using Spring, and Hibernate. So please forgive me if I missed anything obviuos. I have seen plenty of threads around this issue and tried all of the different things suggested so far on those threads with no success.
I am running on WebLogic 9.2 with Hibernate 3.2 and Spring 2.0.6.
I have multiple WAR file that interact with a JAR file. JAR file has all the code for Spring-Hibernate and hbm.xml mapping files. The JAR file resides somewher on the file system and added to the servers classpath.
So far I tried following
<property name="mappingLocations" value="classpath*:*.hbm.xml"/>
<property name="mappingJarLocations" value="file:**/domain.jar"/>
<property name="mappingJarLocations" value="classpath*:domain.jar"/>
<property name="mappingJarLocations" value="classpath*:**/domain.jar"/>
<property name="mappingJarLocations" value="file:**/domain.jar"/>
I have if I provide invalid file location I get following exception during server start up when
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [domain.jar] cannot be resolved to URL because it does not exist
But when It finds the file during startup, it does not throw any exception but it throws follwing exception when web application is trying to access database.
org.springframework.orm.hibernate3.HibernateSystem Exception: Unknown entity: com.test.common.attribute.Priority; nested exception is org.hibernate.MappingException: Unknown entity: com.test.common.attribute.Priority
Caused by: org.hibernate.MappingException: Unknown entity: com.test.common.attribute.Priority
When I copy those hbm.xml mapping files into the WEB-INF everything works fine so I know there is no issue with the mapping files.
Thanks in advance for your help.
Last edited by jmalkan; Oct 22nd, 2007 at 10:12 AM.
Jiggy
-
Nov 21st, 2007, 08:20 AM
#2
Hibernate files in Jars
See the Spring Reference 4.7.2.3 http://static.springframework.org/spring/docs/2.5.x/reference/resources.html#resources-wildcards-in-path-other-stuff
which explains why "classpath*:*.hbm.xml" doesn't work. You can get it to work if you put your hbm.xml files in a specified subdirectory/package, for example "classpath*:res/*.hbm.xml". Or if you put them in the same directories as the corresponding Java classes, you could use "classpath*:com/**/*.hbm.xml", assuming your classes are under the root package "com".
-
Nov 21st, 2007, 08:37 AM
#3
Thanks for the update. I was keeping all my mapping files under the root and I moved them to com.mycompany.mapping package. Just like you would keep struts application resource file and now it finds the files. I wanted all my mapping files in one location instead of spreading them all over the places. It is easier to maintain.
Jiggy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules