jQuery in Action, 2nd edition*
The moose likes Ant, Maven and Other Build Tools and the fly likes [Newbie Issue] hibernate.cfg.xml and hbm.xmls are not packaged by Maven? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "[Newbie Issue] hibernate.cfg.xml and hbm.xmls are not packaged by Maven?" Watch "[Newbie Issue] hibernate.cfg.xml and hbm.xmls are not packaged by Maven?" New topic
Author

[Newbie Issue] hibernate.cfg.xml and hbm.xmls are not packaged by Maven?

Sebi Tamberg
Greenhorn

Joined: Dec 30, 2009
Posts: 4
Hi!

I'm very new to maven and running into some mandatory beginners problem. What I want is to maven along with hibernate. I have read and googled a lot concerning this problem of mine, however, I don't find a solution.

Here's my source dir structure:


compilation is no issue, but when I try and run the class by java -cp .... I get the error:



Obviously, the hibernate.cfg.xml was not copied into the jar. Adding it manually resolves this problem, however, after fixing this issue, the code complains about missing the mapper com.sas.bo.CW.hbm.xml. Hence, Maves does not copy any of the xml files, even though at leas one is in the appropiate resource path.

How can I make Maven include these .xmls when packaging the jar? Any advice is most welcome.

BTW, here's my pom.xml:




Thanks to all advicers in advance

Regs
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

I think your POM may be more complicated that it needs to be, since there are a lot of defaults available, and I'm not even sure if some of the features you're requesting are actually used for the type of program you're describing. But that mostly doesn't matter.

When you build a stand-alone JAR artifact with Maven, fixed classpath resources that need to be copied into the target jar should be placed in the src/main/resources directory subtree. All files and directories in that subtree are copied by the jar plugin verbatim to the target jar. That should be all you need for a standalone app using Hibernate.


Customer surveys are for companies who didn't pay proper attention to begin with.
Sebi Tamberg
Greenhorn

Joined: Dec 30, 2009
Posts: 4

Ahh ... so easy it is and so blind am I ... sorry for that and thank you very much for your response.

I put ALL resources (hibernate.cfg.xml and mapping files *.hbm.xml) in the src/main/resources dir AND corrected the path to the mapping files given in hibernate.cfg.xml to point to the root and, voila, it works now:

src/main/resources/hibernate.cfg.xml
src/main/resources/CW.hbm.xml

with hibernate.cfg.xml =


Thanks & HAPPY NEW YEAR
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Newbie Issue] hibernate.cfg.xml and hbm.xmls are not packaged by Maven?
 
Similar Threads
Filtering problem using maven-read-properties plugin in pom.xml file
Error: ERROR initServletBean, Context initialization failed
Could not resolve dependencies for maven project
Error slf4j-api, I can't exclude slf4j-api for Jboss
Cannot locate the artifact jbossws-native-jaxrpc