In a setup with PF4J 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. |