• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Can't find mapping file

 
Bartender
Posts: 1840
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1840
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic