[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4864) "Cannot read files twice on NativeScanner" exception when using multiple persistence.xml
subes (JIRA)
noreply at atlassian.com
Sun Apr 11 18:01:58 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=36371#action_36371 ]
subes commented on HHH-4864:
----------------------------
This works for me:
@NotThreadSafe
public class MergedPersistenceUnitManager extends DefaultPersistenceUnitManager {
@Override
protected void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo newPU) {
super.postProcessPersistenceUnitInfo(newPU);
/* ++ changed ++ treat RootPU as Jar and remove RootPU so its not duplicate */
newPU.addJarFileUrl(newPU.getPersistenceUnitRootUrl());
newPU.setPersistenceUnitRootUrl(null);
/* -- changed -- */
final String persistenceUnitName = newPU.getPersistenceUnitName();
final PersistenceUnitInfo oldPU = getPersistenceUnitInfo(persistenceUnitName);
if (oldPU != null) {
List<URL> urls = oldPU.getJarFileUrls();
for (URL url : urls) {
newPU.addJarFileUrl(url);
}
List<String> managedClassNames = oldPU.getManagedClassNames();
for (String managedClassName : managedClassNames) {
newPU.addManagedClassName(managedClassName);
}
List<String> mappingFileNames = oldPU.getMappingFileNames();
for (String mappingFileName : mappingFileNames) {
newPU.addMappingFileName(mappingFileName);
}
Properties oldProperties = oldPU.getProperties();
Properties newProperties = newPU.getProperties();
newProperties.putAll(oldProperties);
newPU.setProperties(newProperties);
}
}
}
> "Cannot read files twice on NativeScanner" exception when using multiple persistence.xml
> ----------------------------------------------------------------------------------------
>
> Key: HHH-4864
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4864
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.5.0-Beta-3
> Reporter: Bouiaw
>
> When subclassing DefaultPersistenceUnitManager as described in http://ancientprogramming.blogspot.com/2007/05/multiple-persistencexml-files-and.html in order to have my entities in different jars, Hibernate 3.5-Beta3 throw the following exception (it worked with previous version of Hibernate) :
> java.lang.RuntimeException: error trying to scan <jar-file>: file:/Users/bouiaw/resthub/resthub-core/target/classes/
> at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:700)
> at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:465)
> at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:165)
> at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
> at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:288)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1457)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1397)
> ... 51 more
> Caused by: org.hibernate.AssertionFailure: Cannot read files twice on NativeScanner
> at org.hibernate.ejb.packaging.NativeScanner.getFilesInJar(NativeScanner.java:168)
> at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:393)
> at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:697)
> ... 57 more
--
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