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

  • SEARCH
  • Home
  • 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 8074939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:49:44+00:00 2026-06-05T14:49:44+00:00

I have a problem with java jdk1.6.0_17 and hibernate . I must open a

  • 0

I have a problem with java jdk1.6.0_17 and hibernate .
I must open a hibernate session factory but mapping file (mapper-test.jar) is load by a personaly classLoader (URLClassLoader)

         File map = new File("/opt/sigeco/infowebrepository/mapper/mapper-test.jar");
   File map1 = new File("/opt/sigeco/infowebrepository/mapper/hibernate3.jar");       
          URL[] urls = new URL[] { map.toURI().toURL(),map1.toURI().toURL()};   
          URLClassLoader loader = new URLClassLoader(urls);
          //test load is ok
          loader.loadClass("it.sigeco.infoweb.dao.app.IcFabb");          
          Configuration configuration=new Configuration();          
          configuration.configure( loader.getResource("hibernate.cfg.xml"));       
          configuration.buildSessionFactory();

the problem is:

org.hibernate.MappingException: Resource: it/sigeco/infoweb/dao/app/IcFabb.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:479)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1325)
at testLoad.main(testLoad.java:32)

the hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  <hibernate-configuration>
    <session-factory>
       <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
       <property name="show_sql">true</property>
       <property name="hibernate.cache.use_query_cache">false</property>
       <property name="hibernate.cache.use_second_level_cache">false</property>
      <property name="hibernate.jdbc.use_scrollable_resultset">true</property>
      <mapping resource="it/sigeco/infoweb/dao/app/IcFabb.hbm.xml"/>        
    </session-factory>
 </hibernate-configuration>

if load the mapper-test with build path is success, so the mapper-test is ok.

Seems that the Configuration search the file it/sigeco/infoweb/dao/app/IcFabb.hbm.xml in the system classloader and not in the URLClassLoader, but how do I connect the Configuration with the Loader?

Thank you

  • 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. Editorial Team
    Editorial Team
    2026-06-05T14:49:45+00:00Added an answer on June 5, 2026 at 2:49 pm

    I’ve found one solution. I create a personaly ClassLoader, MapperClassLoader, that extend UrlClassLoader where in costructor:

    MapperClassLoader(URL[] urls)
    {
            super( urls,MapperClassLoader.class.getClassLoader());
    }
    

    where urls contains the jars url. So set the parent loader whit the system class loader.
    After create MapperClassLoader, set the system ClassLoader whit MapperClassLoader

    Thread.currentThread().setContextClassLoader( MapperClassLoader.getInstance());
    

    So the mapper-test.jar is usabile.

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

Sidebar

Related Questions

So I have a problem where Java is telling me that the following line
Good evening ladies and gentlemen, I have a problem with Java Swing that I
I have a problem with my Java progam suddenly exiting, without any exception thrown
I have problem with google map Loading and making center in my java script
I recently have a problem that my java code works perfectly ok on my
I am new to Java. I have problem to understand the relation between anonymous
Possible Duplicate: Java - Regex problem I have list of URLs of types: http://www.example.com/pk/etc
I have a weird problem with a Java Gregorian Calendar: SimpleDateFormat sdf = new
i have a little problem with my java socket code. I'm writing an android
I have a problem concerning a HashMap in Java. To explain the problem in

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.