aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Balazs Zsoldos (JIRA)" <>
Subject [jira] [Commented] (ARIES-681) JPA Container BundleDelegatingClassLoader should look for classes in the provider bundle, too
Date Fri, 17 Jun 2011 19:17:47 GMT


Balazs Zsoldos commented on ARIES-681:


I did not go into the source of EclipseLink but as much as I have seen till now the following

There is are two entity classes and they are in one-to-many relationship. Due to this reason
one of the classes has a property with the definition: Collection<Entity2>. At runtime
I guess eclipselink thinks that a good implementation for this collection could be the IndirectList.
So when it builds up the EntityManagerFactory and the metadata of the entity classes it uses
IndirectList as the type of this property.

However when it comes to the part where it wants to get Class<?> objects out of the
metadata it uses Class.forName(). That works good if the current classloader is the same as
the one that loaded the current class so it works in ordinary webapps.

I could use the Glassfish supported way of persistence entity bundle (which I guess is not
based on the OSGI 4.2 specification) however I would like to use aries blueprint as well other
features from aries and I am not sure they would work with the Glassfish solution.

I would not like to add to my entity bundle "Import-Packages" eclipselink related classes
as I would like to be JPA vendor independent. Of course EclipseLink could try to load the
classes from its own bundle ClassLoader but I am afraid they do not think in OSGI that much
so they will simply use Class.forName().

Due to the reason that JPA vendors use often CGLib and/or ASM to override property types in
entity classes from their own classes (or proxy them or whatever) I thought it would have
been useful to ask at least the bundle classloader of the provider when a class is searched
(from Entity class property Types at runtime)...

With the patch I provided I successfully created a small application that has three bundles
in Glassfish 3.1 (entity bundle, persistence service bundle, a web service bundle). If you
can suggest any other workaround I would be happy to try it but for now I am not sure I can
find anything else.


> JPA Container BundleDelegatingClassLoader should look for classes in the provider bundle,
> ---------------------------------------------------------------------------------------------
>                 Key: ARIES-681
>                 URL:
>             Project: Aries
>          Issue Type: Bug
>          Components: JPA
>    Affects Versions: 0.3
>         Environment: Glassfish 3.0 (EclipseLink 2.0.2), Glassfish 3.1 (EclipseLink 2.2)
>            Reporter: Balazs Zsoldos
>         Attachments: classloadingFromMultipleProviderDuringQuery.0.3.patch
> Currently the BundleDelegatingClassLoader in JPA container only looks for classes in
the bundle of the entitymanager. However the JPA implementation Eclipselink needs some classes
from itself. The reason is that in entity classes the properties that hold mapping of One-To-Many
are converted to EclipseLink list type. See the following exception stacktrace:
> Internal Exception: java.lang.ClassNotFoundException: org.eclipse.persistence.indirection.IndirectList
> 	at org.eclipse.persistence.exceptions.ValidationException.classNotFoundWhileConvertingClassNames(
> 	at org.eclipse.persistence.internal.queries.InterfaceContainerPolicy.convertClassNamesToClasses(
> 	at org.eclipse.persistence.mappings.CollectionMapping.convertClassNamesToClasses(
> 	at org.eclipse.persistence.descriptors.ClassDescriptor.convertClassNamesToClasses(
> 	at org.eclipse.persistence.sessions.Project.convertClassNamesToClasses(
> 	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(
> 	... 83 more
> Caused by: java.lang.ClassNotFoundException: org.eclipse.persistence.indirection.IndirectList
> 	at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(
> 	at org.apache.felix.framework.ModuleImpl.access$100(
> 	at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(
> 	at java.lang.ClassLoader.loadClass(
> 	at org.apache.felix.framework.ModuleImpl.getClassByDelegation(
> 	at org.apache.felix.framework.Felix.loadBundleClass(
> 	at org.apache.felix.framework.BundleImpl.loadClass(
> 	at org.apache.aries.jpa.container.unit.impl.BundleDelegatingClassLoader$
> 	at org.apache.aries.jpa.container.unit.impl.BundleDelegatingClassLoader$
> 	at Method)
> 	at org.apache.aries.jpa.container.unit.impl.BundleDelegatingClassLoader.findClass(
> 	at java.lang.ClassLoader.loadClass(
> 	at java.lang.ClassLoader.loadClass(
> 	at java.lang.Class.forName0(Native Method)
> 	at java.lang.Class.forName(
> 	at
> 	at org.eclipse.persistence.internal.queries.InterfaceContainerPolicy.convertClassNamesToClasses(
> 	... 87 more

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message