[JIRA] (HCANN-128) Reflection does not use ClassLoaderService
by Marcus Ilgner (JIRA)
Marcus Ilgner ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=608faf0... ) *created* an issue
Hibernate Commons Annotations ( https://hibernate.atlassian.net/browse/HCANN?atlOrigin=eyJpIjoiZWEyOTk1Mj... ) / Bug ( https://hibernate.atlassian.net/browse/HCANN-128?atlOrigin=eyJpIjoiZWEyOT... ) HCANN-128 ( https://hibernate.atlassian.net/browse/HCANN-128?atlOrigin=eyJpIjoiZWEyOT... ) Reflection does not use ClassLoaderService ( https://hibernate.atlassian.net/browse/HCANN-128?atlOrigin=eyJpIjoiZWEyOT... )
Issue Type: Bug Affects Versions: 5.1.2 Assignee: Sanne Grinovero ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) Created: 01/Mar/2023 07:40 AM Environment: Hibernate Reactive 1.0.3, PF4J 3.9.0, Temerin 17, Linux, PostgreSQL, Vert.x Priority: Major Reporter: Marcus Ilgner ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=608faf0... )
In a setup with PF4J ( https://pf4j.org/ ) with entities from multiple plugins, where each plugin has its own ClassLoader.
After registering a ClassLoaderService with the service registry which knows about all these PluginClassLoader and adding the annotated entities through Configuration#addAnnotatedClass , the entities can be loaded just fine.
Unfortunately, it is not possible to add a @ManyToOne annotation for classes from different classloaders: one of the plugins has a dependency on the other and I had hoped to use classes from the other plugin.
But when adding that @ManyToOne annotation, a java.lang.NoClassDefFoundError is thrown.
This seems to occur at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredMethodProperties(JavaXClass.java:97) where toClass().getDeclaredMethods() is invoked. This being a part of java.lang.Class , it doesn’t have access to the ClassLoaderService and has no chance to look up the associated class.
This happens independently from the order in which classes were added with addAnnotatedClass : even if the first class has already been added and scanned successfully, the second class will fail to scan.
( https://hibernate.atlassian.net/browse/HCANN-128#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HCANN-128#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:65be9f2 )
1 year, 2 months