That sounds the most likely.
After a bit of research I've came across a bit of documentation on the middleware which I didn't quite understand the first time I've read it:
Libraries deployed under your Extension folder will be loaded in the Extension Class Loader. This means that you can change that specific library without affecting other Extensions.
Libraries shared under the __lib__ folder are loaded in the parent Class Loader. If you change any of these dependencies it will affect all Extensions that use them.
So they are indeed loaded by two class loaders!
However, this defeats my previous workaround and I am back with the problem of unable to load the emf:
javax.persistence.PersistenceException: No Persistence provider for EntityManager named xxx
Upon closer examination, isn't javax.persistence package name inside the objectdb.jar file? So if there is a problem loading objectdb.jar at runtime, how can we get the exception contained inside the package?
Is it perhaps only part of the jar is being loaded? Is that even possible? Or maybe it has to do with different class loaders?
Here is the stack trace again:
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
extension.LoginEventHandler.handleServerEvent(LoginEventHandler.java:103)
...
I also tried to confirm that jars under the extension folder loads properly, so I put the ObjectDB points tutorial (exported) jar into my current web app, and I created a Point object successfully in code. So I think objectdb.jar is getting loaded alright, but parts of it is not working somehow...
Edit: I took a look at the Persistence.java source code and extracted the method that is throwing the exception:
/* */ public static EntityManagerFactory createEntityManagerFactory(String paramString, Map paramMap)
/* */ {
/* 73 */ EntityManagerFactory localEntityManagerFactory = null;
/* 74 */ PersistenceProviderResolver localPersistenceProviderResolver = PersistenceProviderResolverHolder.getPersistenceProviderResolver();
/* */
/* 76 */ List localList = localPersistenceProviderResolver.getPersistenceProviders();
/* */
/* 78 */ for (PersistenceProvider localPersistenceProvider : localList) {
/* 79 */ localEntityManagerFactory = localPersistenceProvider.createEntityManagerFactory(paramString, paramMap);
/* 80 */ if (localEntityManagerFactory != null) {
/* */ break;
/* */ }
/* */ }
/* 84 */ if (localEntityManagerFactory == null) {
/* 85 */ throw new PersistenceException("No Persistence provider for EntityManager named " + paramString);
/* */ }
/* 87 */ return localEntityManagerFactory;
/* */ }
It looks like either the list of local PersistenceProviders is 0 or none of them is able to create an emf with the given string...
This is quite strange since we are able to create one when we switched class loaders...not sure how to make sense out of it...