-->
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.  [ 1 post ] 
Author Message
 Post subject: mapping files and URLClassLoader
PostPosted: Mon Jun 11, 2012 3:59 am 
Newbie

Joined: Mon Jun 11, 2012 3:39 am
Posts: 1
I have a problem with java jdk1.6.0_17 and hibernate . I must open an hibernate session factory but mapping file (mapper-test.jar) is load by a custom classLoader (URLClassLoader) - the web app is deployed on JBoss 4.3.2

File map = new File("/opt/mapper/mapper-test.jar");
File map1 = new File("/opt/mapper/hibernate3.jar");
URL[] urls = new URL[] { map.toURI().toURL(),map1.toURI().toURL()};
URLClassLoader loader = new URLClassLoader(urls);
//test load is ok
loader.loadClass("com.mydomain.dao.app.IcFabb");
Configuration configuration=new Configuration();
configuration.configure( loader.getResource("hibernate.cfg.xml"));
// the following statement will throw a MappingException
configuration.buildSessionFactory();

this is the throwed Exception:

org.hibernate.MappingException: Resource: com/mydomain/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="com/mydomain/dao/app/IcFabb.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Seems that the Configuration searches the file com/mydomain/dao/app/IcFabb.hbm.xml in the system classloader and not in the URLClassLoader, so how do I connect the Configuration with the Loader?

Thank you


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

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.