[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2108) org.hibernate.MappingNotFoundException: file:
Barry Pearce (JIRA)
noreply at atlassian.com
Thu Oct 26 21:03:06 EDT 2006
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2108?page=comments#action_24995 ]
Barry Pearce commented on HHH-2108:
-----------------------------------
And still an issue in 3.2.0GA.
Simply running the below code on the files twice generates the error.
import java.io.File;
import java.io.IOException;
import org.hibernate.cfg.Configuration;
public class HibernateMappingCacheGen
{
private static Configuration config;
public static void main(String[] args)
{
System.out.println("[Hibernate Mapping Cache Generation Started]");
config = new Configuration();
process(new File(args[0]));
System.out.println("[Hibernate Mapping Cache Generation Complete]");
}
public static void process(File pathname)
{
for (String filename : pathname.list())
{
File f = new File(pathname.getPath(), filename);
if (! f.isDirectory())
{
System.out.println(" * Generating cache for " + f.getName());
config.addCacheableFile(f);
}
else
{
try
{
process(new File(f.getCanonicalPath()));
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
> org.hibernate.MappingNotFoundException: file:
> ----------------------------------------------
>
> Key: HHH-2108
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2108
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.2.0.cr4
> Environment: Hibernate 3.2.0cr4, SQL Server 2000
> Reporter: Courtney Arnold
> Attachments: Configuration.hbm.xml, Configuration.java, Configuration.java, ConfigurationTest.java, hibernate3.jar
>
> Original Estimate: 5 minutes
> Remaining: 5 minutes
>
> I receive the following error while trying to add a cacheable configuration file to the configuration:
> org.hibernate.InvalidMappingException: Could not parse mapping document from file F:\products\common\resources\hibernate\hbm\org\waterford\product\data\db\hibernate\Product.hbm.xml
> at org.hibernate.cfg.Configuration.addCacheableFile(Configuration.java:359)
> at org.hibernate.cfg.Configuration.addCacheableFile(Configuration.java:364)
> at org.waterford.common.data.db.hibernate.HibernateDbBroker._addMappings(HibernateDbBroker.java:568)
> at org.waterford.common.data.db.hibernate.HibernateDbBroker._getConfiguration(HibernateDbBroker.java:477)
> at org.waterford.common.data.db.hibernate.HibernateDbBroker._initSessionFactory(HibernateDbBroker.java:668)
> at org.waterford.common.data.db.hibernate.HibernateDbBroker.setDb(HibernateDbBroker.java:189)
> at org.waterford.sm.db.smdbinterface.HibSmDbInterface.connect(HibSmDbInterface.java:426)
> at org.waterford.sm.db.smdbinterface.HibSmDbInterface.<init>(HibSmDbInterface.java:333)
> at org.waterford.sm.db.smdbinterface.factory.HibSmDbInterfaceFactory._getInstance(HibSmDbInterfaceFactory.java:51)
> at org.waterford.sm.db.smdbinterface.factory.HibSmDbInterfaceFactory.getInstance(HibSmDbInterfaceFactory.java:24)
> at org.waterford.sm.license.LicenseManager._getDbInterface(LicenseManager.java:48)
> at org.waterford.sm.license.LicenseManager.loadFromDB(LicenseManager.java:218)
> at org.waterford.sm.license.LicenseManager.init(LicenseManager.java:183)
> at org.waterford.sm.license.LicenseManager.initLicensing(LicenseManager.java:118)
> at org.waterford.sm.SMFrame.init(SMFrame.java:284)
> at org.waterford.sm.SMApp.<init>(SMApp.java:76)
> at org.waterford.sm.SMApp.main(SMApp.java:213)
> Caused by: org.hibernate.MappingNotFoundException: file: F:\products\common\resources\hibernate\hbm\org\waterford\product\data\db\hibernate\Product.hbm.xml not found
> at org.hibernate.cfg.Configuration.addCacheableFile(Configuration.java:349)
> ... 16 more
> I have looked at the source for org.hibernate.cfg.Configuration(addCacheableFile) and the problem lies in the if /else statement around line 348. Prior to this statement a cached configuration file was loaded into the "doc" object. So the if statement "if (doc == null && xmlFile.exists())" will return false. Doing so, execution continues on the else statement that executes "throw new MappingNotFoundException("file", xmlFile.toString());". Due to this, no cached files can be loaded into the configuration, only uncached files can be loaded. The else statement needs to be modified to be "else if (doc == null)".
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list