[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| 
Re: [eclipselink-users] Eclipse RCP - EntityManagerFactory == null
 | 
Tom Ware skrev:
Hi Christian,
  I apologize if I have missed this earlier in the thread, but the most 
common reason the persistence unit cannot be found is that the correct 
classloader has not been provided at EntityManagerFactory creation 
time.  We need access to a classloader that can load 
META-INF/persistence.xml as a resource.
  Here's what we do in the example:
    private EntityManagerFactory getEntityManagerFactory() {
        if (emf == null) {
            HashMap properties = new HashMap();
            properties.put(PersistenceUnitProperties.CLASSLOADER, 
this.getClass().getClassLoader());
            emf = new PersistenceProvider().createEntityManagerFactory(
                    PU_NAME,
                    properties);
        }
        return emf;
    }
Thanks for replying taking the time to reply :-)
I've actually managed to do this part, and because of it I even got a 
little ouput in the debug part (by putting in more stuff in the 
hashmap). And for some odd reason it no longer complains about not 
finding the persistence bundle, though I havent changed anything. So I'm 
sort of at a loss what do try next. Though trying to implement 
everything once more from scratch would seem like a 'good idea' right 
about now.
But is it a requirement to have the EntityManagerFactory in the same 
bundle as the persistence.xml?
--
Sincerly
Christian Michelsen