Results 1 to 3 of 3

Thread: org.springframework.orm.hibernate3.HibernateSystem Exception: Unknown entity

  1. #1
    Join Date
    Jan 2006
    Posts
    22

    Default 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

  2. #2

    Default 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".

  3. #3
    Join Date
    Jan 2006
    Posts
    22

    Default

    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
  •