To get the entitymanager working in an eclipse rcp application I made the following changes in the current source which I got from the cvs
1. Modification
---------------
reason: does not find the resource
file: Persistence.java
package: javax.persistence
method: findAllProviders()
old:
Code:
Enumeration<URL> resources = loader.getResources("META-INF/services/" + PersistenceProvider.class.getName() );
new:
Code:
Enumeration<URL> resources = Persistence.class.getClassLoader().getResources("META-INF/services/"+ PersistenceProvider.class.getName());
2. Modification
---------------
reason: does not find the resource
file: Ejb3Configuration.java
package: org.hibernate.ejb
method: createEntityManagerFactory()
old:
Code:
Enumeration<URL> xmls = Thread.currentThread().getContextClassLoader().getResources( "META-INF/persistence.xml" );
new:
Code:
Enumeration<URL> xmls = getClass().getClassLoader().getResources("META-INF/persistence.xml");
3. Modification
---------------
reason: the url protocol bundleresource: could not be resolved
file: Ejb3Configuration.java
package: org.hibernate.ejb
method: createEntityManagerFactory()
old:
Code:
URL url = xmls.nextElement();
new:
Code:
import org.eclipse.core.runtime.Platform;
.....
URL urlOriginal = xmls.nextElement();
URL url = Platform.asLocalURL(urlOriginal);
The 3rd modification is for sure the biggest hack but finally it worked. I'm not sure if there would be a better solution because I do Java programming only since a few months.