Ok, After a few debug, it realy seems the DTDEntityResolver class has a problem somehow...
Here it is :
When configuring hibernate (new Configuration().configure("hibernate.cfg.xml")), hibernate start to read the 'hibernate.cfg.xml' file using the xerces XML Parser...
When reading the file, the resolveEntity function of class DTDEntityResolver is called.
It then calls resolveInHibernateNamespace at line 68 of DTDEntityResolver.java and does somethings whether the return is null or not.
But at line 104 of the DTDEntityResolver.java :
Code:
protected InputStream resolveInHibernateNamespace(String path) {
return this.getClass().getClassLoader().getResourceAsStream( path );
}
When I evaluate the "this.getClass().getClassLoader()" in debug, it returns null !?!! What does it means ?!?
I think this call to getClassLoader should be protected as it is said in the documentation that
Quote:
Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader.
[...]If this object represents a primitive type or void, null is returned.
...
So sometimes, it could return "null" ... and the call to getResourceAsStream should not like it!
Anyway, in our case, I dont understand why this.getClass().getClassLoader() returns null has this.getClass() returns "class org.hibernate.util.DTDEntityResolver" which normally has been loaded by the XMLHelper class at instanciation.
So why does the getClassLoader() return null ???
Someone ?
Anyway, getting back to the resolveInHibernateNamespace function, it should check the return of "this.getClass()" and "this.getClass().getClassLoader()", no ?
Maybe an old bug ? See
http://opensource.atlassian.com/projects/hibernate/browse/HB-1370