Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't find mapping file

 
Mike London
Ranch Hand
Posts: 1208
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1208
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic