Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 152259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:35:29+00:00 2026-05-11T09:35:29+00:00

I have some *.hbm.xml files that are placed in the same folder at the

  • 0

I have some *.hbm.xml files that are placed in the same folder at the hibernate.cfg.xml file. Now, I want to map some other *.hbm.xml files that are in a subfolder of this folder. How could I do it? Thanks!

here’s part of my hibernate.cfg.xml:

   <hibernate-configuration>         <session-factory name='MySessionFactory'>              <!-- some hibernate properties here -->                <!--This below works fine-->              <mapping resource='A.hbm.xml'/>               <!--This doesn't-->              <mapping resource='/dir/B.hbm.xml'/>          </session-factory>    </hibernate-configuration> 

This is part of my Ant file:

        <target name='generateHibernateSql'>          <taskdef name='SchemaExportTask'             classname='org.hibernate.tool.hbm2ddl.SchemaExportTask'         >             <classpath>                 <pathelement location='${build.classes.main.dir}'/>                 <pathelement location='${base.configuration.hibernate.dir}'/>                 <path refid='build.classpath.lib'/>             </classpath>         </taskdef> 

here’s my folder structure

${base.configuration.hibernate.dir}    | hibernate.cfg.xml    | A.hbm.xml    |--dir    |---| B.hbm.xml ${build.classes.main.dir} 

[Edit]

I have first tried and failed as Maurice suggested, changed the line to

 <mapping resource='dir/B.hbm.xml'/> 

still gives the same error:

Schema text failed: Could not parse mapping document from resource dir/B.hbm.xml 

and then I went on to try adding into my schemaexpoert as Mark suggested. It then wouldn’t even find my ‘A.hbm.xml’ anymore. Giving off the error:

Schema text failed: Could not parse mapping document from resource A.hbm.xml 

My SchemaExportTask now looks like:

        <SchemaExportTask             config='${base.configuration.hibernate.dir}\hibernate.cfg.xml'             quiet='no'             text='no'             drop='no'             delimiter=';'             create='yes'             output='${dist.database.dir}\schema-export.sql'         >             <fileset dir='${base.configuration.hibernate.dir}'>                 <include name='**/*.hbm.xml'/>             </fileset>         </SchemaExportTask> 

[Resolved]

The conclusion is that I was just really stupid. It had nothing to do with being in a different directory. I got confused because I was changing two things at once testing phase and then I blamed it all on the innocent ‘directory change’. Sorry for wasting everyone’s time.

If anyone is interested, here was what happened. I did some XSLT translation using a local DTD file, and specified the local DTD file with a relative path in my XSL file. But I put the generated hbm.xml files into a difference directory — hence SchemaExportTask cannot find the DTD file anymore and failed to parse the new hbm.xml files. And for some stupid reason, I thought the following completely different error messages meant the same thing…. Thanks a lot to Mark for reminding me that people wrote error messages for a good reason! Adding fileset still doesn’t work now, but I now know to read error meassages…I’m sure I’ll fix it soon. =.=”

Schema text failed: resource: B.hbm.xml not found Schema text failed: Could not parse mapping document from resource dir/B.hbm.xml 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:35:29+00:00Added an answer on May 11, 2026 at 9:35 am

    For general Hibernate usage I agree with change Maurice suggested but thought I would give more of an explanation. Hibernate mapping files are loaded as resources from the classpath. As you have ${base.configuration.hibernate.dir} on your classpath you must give the path of the mapping file relative to this therefore the front / should be removed.

    For using the schema export tool from ant the docs say that you should define the mapping files as a fileset rather than expect them to be found on the classpath. See

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 71k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You would need to use PGP or something similar on… May 11, 2026 at 1:16 pm
  • added an answer A couple of things that may cause this. You do… May 11, 2026 at 1:16 pm
  • added an answer Basically, anything you store in a way accessible to your… May 11, 2026 at 1:16 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.