views:

40

answers:

2

Hi, i am working on a spring mvc app using hibernate and i am having some trouble compiling and running my code.

This is because it cannot find my FileObject.hmb.xml whenever i try to create a session factory bean.

my bean looks like this

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource1"></property>
    <property name="mappingResources">
        <list>
            <value>FileObject.hmb.xml</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
        </props>
    </property>
</bean>

And the FileObject.hmb.xml resides in the root of my WAR folder. i have tried to move this file to different folders including the actual src folder and providing the correct path in the session factory but it still gives me a FileNotFoundException.

is this because java doesnt recognise a hello.hmb.xml type of file? Most if not all file formats are like this: name.extension

hibernate mapping files seems to be different though

Follow-up: As I have noted before, I have tried to put my .hbm.xml in numerous places including the src directory and still wont work.

My project structure is similar to this:

project structure

I have tried to put the file inside the root dir of war, WEB-INF, classes and as said before, in my actual src directory.

I never knew it was this much hassle just to get hibernate and spring running successfully.

+1  A: 

MappingResources can only receive paths relative to your classpath.

http://forum.springsource.org/showthread.php?t=87988

Aaron Saunders
Whats the appropriate way?
jonney
see edits, link included
Aaron Saunders
I did and the OP is having a different exception then me. my exception is that it simply cant find the file ie FileNotFoundException.
jonney
@jonney can you update the question to reflect excactly where the hbm file is and what you have in your configuration file
Aaron Saunders
A: 

If the .hbm.xml files are in a directory tree in your CLASSPATH, try putting the path starting from the root of the CLASSPATH:

<value>foo/bar/persistence/hibernate/FileObject.hmb.xml</value> 

Directory path I use is just an example.

duffymo