Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Saloon Keeper
Posts: 22503
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sebi Tamberg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic