I'm confused about class visibility in OSGi. I'm running Apache Felix and loading the following bundles:
- the
antlr
,asm
,jpa
andcore
bundles from eclipselink - an OSGi-fied jar for
javax.persistence
1.99 - an OSGi-fied jar with the
com.mysql.jdbc
driver - a bundle of my own that contains annotated entity classes and a
persistence.xml
- another bundle of my own that calls
Persistence.createEntityManagerFactory(String, Map)
Now, what I'm confused about is which bundle must be able to see the MySQL driver. I thought this would be the bundle creating the EntityManagerFactory, but I get ClassNotFound errors when I import in that manifest. Next, I tried importing it from the eclipselink jpa
bundle's manifest, but wrong again. Only when I import it from the manifest of the bundle containing the persistence unit (entity classes and persistence.xml
), it works.
So, seemingly the database driver is looked up by the clasloader for the PU's bundle, but that doesn't make sense to me. What's going on?
I can't seem to find a straightforward documentation for this. These slides give some hints, but aren't exactly comprehensive.