I am using Hibernate Entity Manager 3.31GA, annotations 3.30GA and core 3.2.
I have an application with a 'plugin' system. The plugins are in JARs in a subdirectory. The main application searches the JARs for classes implementing a particular interface, and loads those using URLClassLoader.
The problem arises when one of these plugins tries to use the Entity Manager. The plugin JAR has a persistence.xml file, but the system class loaders don't seem to 'know' about this JAR because it isn't on the class path.
The usual thing is to get the following:
Code:
INFO - Hibernate EntityManager 3.3.1.GA
DEBUG - Look up for persistence unit: WhateverPU
INFO - Could not find any META-INF/persistence.xml file in the classpath
java.util.concurrent.ExecutionException: javax.persistence.PersistenceException: No Persistence provider for EntityManager named WhateverPU
etc...
I also tried using Ejb3Configuration (out of desperation because it's not portable) - but here I suffer from lack of documentation. Can I somehow give a URL to the persistence.xml in the JAR file? If I try to specify everything else programmatically, without referring to the persistence.xml, Hibernate seems to expect .hbm.xml files for classes that are actually annotated:
Code:
Ejb3Configuration ejbc = new Ejb3Configuration();
return ejbc.addClass(Cards.class)
.addClass(Places.class)
.addProperties(map)
.buildEntityManagerFactory();
And this produces:
Code:
INFO - Reading mappings from resource: com/tvg_tech/holypass/general/Cards.hbm.xml
INFO - Reading mappings from resource: com/tvg_tech/holypass/general/Cards.hbm.xml
java.util.concurrent.ExecutionException: org.hibernate.MappingNotFoundException: resource: com/xxx/xxx/general/Cards.hbm.xml not found
Many thanks,
Shalom Crown