Hi,
On 26.10.2009, at 23:20, Joel Schuster wrote:
I've been able to get EclipseLink to work against and embedded Derby
instance within Felix working from the Equinox examples.
However, this is only when using the standard OSGi BundleActivator
implementation, not when using iPojo.
As all the rest of my system is iPojo based I'd like to do the same
for my data layer. However, because the EntityManagerFactory
creation in my @Validate is being called by the iPojo factory the
persistence.xml file isn't found. There's seems to be a requirement
that needs the EntityManagerFactory be called within the same class
loader that the persistence.xml file is available.
Interesting. I never used EclipseLink but sounds like a good
opportunity to try. The only difference between the start method of
the activator and the @Validate method is the thread executing those
methods. The bundle activator is executed by the/a thread of the OSGi
framework. The @Validate method is generally executed by the
InstanceCreator thread (The thread aiming to parse and create
<instance> elements from the metadata.xml. (obviously, if you don't
create your instance like that then it will not use this thread).
I suspect that the thread may influence how is loaded the
persistence.xml (maybe by using the TCCL (Thread Context
Classloader)). On Equinox, they have this concept of ContextFinder
that might also be used (are you on Felix of Equinox, or another
implementation ?).
You can try to set the TCCL of the thread to your class loader (the
famous OSGi hack) :
Thread.currentThread().setContextClassLoader(getClass
().getClassLoader());
However this is not really clean in an OSGi environment.
I will definitely investigate the issue, it also might be a good idea
for a handler managing this complexity for you (i.e. the eclipse link
interactions)
Regards,
Clement
Thoughts on how to reconcile this issue?
________________________________
Joel Schuster
Senior Software Engineer
NAVSYS Corporation
14960 Woodcarver Road, Colorado Springs, CO 80921
719-481-4877