Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes Can't find mapping file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Can Watch "Can New topic
Author

Can't find mapping file

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1075
In my hibernate configuration file, I try to import the mapping to my message class. The actual mapping file is in my (My)Eclipse "src" folder in the project.

<mapping resource="src/Message.hbm.xml"/>

When I run my Ant task to build this project, I get a

org.hibernate.MappingNotFoundException: resource: src/Message.hbm.xml not found.

The class files are in the same folder ("${src}") and they have a package that's correctly generated in the bin output folder.

Does anyone see what I am doing wrong? I've tried using full paths (/src/...) and including the package name, but these ideas didn't fix the problem.

Thanks very much in advance.

M
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

I think this is a classpath issue. I think the src directory is the root of the classpath and not needed in the mapping

So instead of

<mapping resource="src/Message.hbm.xml"/>

use

<mapping resource="Message.hbm.xml"/>

Now having said that, Why isn't your Message class and mapping file in a package structure. Having them at the root of your classpath isn't a really good idea.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

What is your package structure.

For instance, if it is com.javaranch.model, there for the .java files are in src/com/javaranch/model/Message.java

then your mapping should be

<mapping resource="com/javaranch/model/Message.hbm.xml"/>

Mark
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1075
Mark,

Thanks, yes it worked with just the name and not the "src". I was trying to get an initial example working so I was changing directories around a bit and just have the Java files in the "src" folder. However, these files do have packages so the output, at least, is in packages.

Thanks very much for your reply.

M
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't find mapping file