These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: org.hibernate.MappingException: Resource: .hbm.xml not found
PostPosted: Fri Jan 20, 2006 2:21 pm 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hi - This was working...
Problem setup... I'm creating some common services which are packaged in a .jar file for use in applications. The persistant classes' .hbm.xml files are in the package in which the class resides. I have the Hibernate.cfg.xml located in the output directory of the eclipse project. So it seems Hibernate can locate the Hibernate.cfg.xml file but can not locate any of the mapped resources. I've looked around on for someone else with this problem, but haven't found anything relevent. Note the using application can find the classes I'm refering to.

Any assistence would be greatly appreciated.


Hibernate version: 3.1

Mapping documents:
Hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@xxxx:xxxx:xxxx</property>
<property name="connection.username">user</property>
<property name="connection.password">user</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->

<mapping resource=".\com\thomson\west\foundations\FoundationsOnWhatVO.hbm.xml"/>
<mapping resource="com\thomson\west\foundations\context\AppPropertyVO.hbm.xml"/>
... and more...
</session-factory>
</hibernate-configuration>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
Exception msg = org.hibernate.MappingException: Resource: .\com\thomson\west\foundations\FoundationsOnWhatVO.hbm.xml not found

java.lang.ExceptionInInitializerError
at com.thomson.west.foundations.daos.DBDAO.<init>(DBDAO.java:54)
at com.thomson.west.foundations.daos.DBDAOFactory.createDAO(DBDAOFactory.java:52)
at com.thomson.west.foundations.daos.DAOFactoryBuilder.getRetrievalDAO(DAOFactoryBuilder.java:109)
at com.thomson.west.foundations.transport.AppDBInitVisitor.retrieveApp(AppDBInitVisitor.java:59)
at com.thomson.west.foundations.transport.AppDBInitVisitor.initialize(AppDBInitVisitor.java:39)
at com.thomson.west.foundations.transport.AppDBInitVisitor.visit(AppDBInitVisitor.java:133)
at com.thomson.west.foundations.context.ApplicationImpl.accept(ApplicationImpl.java:800)
at com.thomson.west.foundations.transport.AppDBInitVisitor.retrieveUnique(AppDBInitVisitor.java:147)
at com.thomson.west.foundations.transport.TransportBuilder.getApp(TransportBuilder.java:142)
at com.thomson.west.foundations.FoundationsBuilder.eagerPopulate(FoundationsBuilder.java:146)
at com.thomson.west.foundations.FoundationsBuilder.<init>(FoundationsBuilder.java:106)
at FirstTestApp.runTest(FirstTestApp.java:66)
at FirstTestApp.main(FirstTestApp.java:58)
Caused by: com.thomson.west.foundations.utility.IssueEncounteredException: com.thomson.west.foundations.daos.HibernateUtil Initial SessionFactory creation failed.Resource: .\com\thomson\west\foundations\FoundationsOnWhatVO.hbm.xml not found
at com.thomson.west.foundations.daos.HibernateUtil.<clinit>(HibernateUtil.java:54)
... 13 more
Caused by: java.lang.ExceptionInInitializerError
... 14 more
Caused by: org.hibernate.MappingException: Resource: .\com\thomson\west\foundations\FoundationsOnWhatVO.hbm.xml not found
at com.thomson.west.foundations.daos.HibernateUtil.<clinit>(HibernateUtil.java:53)
... 13 more


Name and version of the database you are using:
Oracle 10g

The generated SQL (show_sql=true):
NA
Debug level Hibernate log excerpt:
NA

_________________
Dave Ziebol


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 6:06 pm 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
So the mapping files are not where you declare them in the config file

Code:
<mapping resource=".\com\thomson\west\foundations\FoundationsOnWhatVO.hbm.xml"/>
<mapping resource="com\thomson\west\foundations\context\AppPropertyVO.hbm.xml"/>

Are you sure FoundationsOnWhatVO location starts with a "." for example?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 6:24 pm 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
No, sorry that was some test code, there should be no .\ in the front.

Basically when I use my created .jar file in a test application and I include the Hibernate.cfg.xml in the source folder of the test app then the test app can find my classes in the jar file and hibernate can find its Hibernate.cfg.xml but Hibernate can not seem to locate the various .hbm.xml resource files listed.

I have a workaround whereby when I add all the persistent classes within HibernateUtil in the process of building a session factory. The code ends up as such...
Code:
    public static final SessionFactory sessionFactory;

    static {
       String whereAmI = HibernateUtil.class.getName();
        try {
            // Create the SessionFactory from hibernate.cfg.xml
           
           sessionFactory = new Configuration().configure()
           .addClass(com.thomson.west.foundations.FoundationsOnWhatVO.class)
           .addClass(AppPropertyVO.class)
           .addClass(TrAuditEventTypeVO.class)
           .addClass(TrAuditEventVO.class)
           .addClass(TrAuditValueVO.class)
           .addClass(ClobValueVO.class)
           .addClass(AppEventVO.class)
           .addClass(PropertyValueVO.class)
           .addClass(XPropertyVO.class)
           .addClass(ErrorValueVO.class)
           .addClass(ErrorEventVO.class)
           .addClass(ApplicationImpl.class)
           .addClass(com.thomson.west.foundations.security.server.AppFunctionalityVO.class)
           .addClass(FunctionalityVO.class)
           .addClass(RequiredRoleVO.class)
           .addClass(com.thomson.west.foundations.security.server.AppFuncReqRoleVO.class)
           .buildSessionFactory();

            //sessionFactory = new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
           String msg = new String();
           msg = whereAmI + " Initial SessionFactory creation failed." + ex.getMessage();
            log.error(msg);
            //ex.printStackTrace();
            ex.fillInStackTrace();
            throw new IssueEncounteredException(new ExceptionInInitializerError(ex), msg);
        }
    }

Which is not something which is exactly "pleasing" to me, but my delivery looms and I'm expecting few new classes in this service once I have the requirements met. On the otherhand the mappings are out of the Hibernate.cfg.xml where they could get futzed up by users... So maybe this is a good thing.

Thanks

Dave Ziebol

_________________
Dave Ziebol


Top
 Profile  
 
 Post subject: Re: org.hibernate.MappingException: Resource: .hbm.xml not f
PostPosted: Sat Jan 21, 2006 12:35 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
dziebol wrote:
<mapping resource=".\com\thomson\west\foundations\FoundationsOnWhatVO.hbm.xml"/>
<mapping resource="com\thomson\west\foundations\context\AppPropertyVO.hbm.xml"/>
... and more...


Shouldnt this be

Code:
  <mapping resource="com/thomson/west/foundations/FoundationsOnWhatVO.hbm.xml"/>
     <mapping resource="com/thomson/west/foundations/context/AppPropertyVO.hbm.xml"/>
... and more...


Replaced the backward slashes with forward slashes!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 11:01 am 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
I tried replacing the slashed, with no luck

So that wasn't it.

Dave Ziebol

_________________
Dave Ziebol


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 11:46 pm 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
if u are using eclipse packaging, make sure that all hbm.xml files are packaged in to the jar files . i can happen sometimes :)

but as per the exception stack trace you have given ,
the problem is with the dot in front of mapping resource= ... line in hibernate.cfg.xml

_________________
sHeRiN
thanks for your ratings ...... :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.