Hi,
I have a problem with the auto discovery of the orm.xml file. I'm running Glassfish v2 in a Windows environment. When I deploy my application as an exploded EAR, the org.hibernate.ejb.EJB3Configuration class cannot find the orm.xml in the META-INF directory of my EJB module. Looking at the code in EJB3Configuration, we can find the following:
Code:
private void scanForXmlFiles(URL jar, List<NamedInputStream> hbmxmls, final XML_SEARCH searchType) {
if (searchType == XML_SEARCH.NONE) return;
if (jar == null) log.error( "Container is providing a null PersistenceUnitRootUrl: discovery impossible");
final boolean searchforORMFiles = searchType == XML_SEARCH.BOTH || searchType == XML_SEARCH.ORM_XML;
final boolean searchforHBMFiles = searchType == XML_SEARCH.BOTH || searchType == XML_SEARCH.HBM;
Iterator it = ArchiveBrowser.getBrowser(
jar, new ArchiveBrowser.Filter() {
public boolean accept(String filename) {
return (searchforHBMFiles && filename.endsWith( ".hbm.xml" ) )
|| (searchforORMFiles && filename.endsWith( META_INF_ORM_XML ) )
;
}
}
);
while ( it.hasNext() ) {
InputStream stream = (InputStream) it.next();
hbmxmls.add( new NamedInputStream("", stream) );
}
}
In the anonymous implementation of the Archive.Filter class, we see that the file name has to end with "META-INF/orm.xml" (value of the META_INF_ORM_XML constant). In a Windows environment and when the ArchiveBrowser is an instance of the DirectoryArchiveBrowser, the file name is an absolute file path that uses the Windows path seperator (ex: C:\path\to\application\ejb3module\META-INF\orm.xml). Hence, the file isn't found even though it's there.
Does anyone know of a work around for this problem? Should the EJB3Configuration class be modified to handle this particular scenario or is this something the DirectoryArcrhiveBrowser should take care of (in which case I will redirect my query to the appropriate forum)?
Thanks for your help.
JBoss Common Core: 2.2.1 SNAPSHOT
Hibernate Core version: 3.2.5
Hibernate Entity Manager version: 3.3.1
Hibernate Annotations version: 3.3.0