From d436b98557cd9e54e2ea97181b71f419ba1d08c3 Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Mon, 16 Dec 2013 14:12:49 -0500 Subject: [PATCH] HHH-8655 Classloader conflicts with embedded OSGi frameworks Conflicts: hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiClassLoader.java --- .../main/java/org/hibernate/osgi/OsgiClassLoader.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiClassLoader.java b/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiClassLoader.java index 97c8bbd80f..7a090db958 100644 --- a/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiClassLoader.java +++ b/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiClassLoader.java @@ -51,9 +51,17 @@ public class OsgiClassLoader extends ClassLoader { private Map> classCache = new HashMap>(); private Map resourceCache = new HashMap(); + + public OsgiClassLoader() { + // DO NOT use ClassLoader#parent, which is typically the SystemClassLoader for most containers. Instead, + // allow the ClassNotFoundException to be thrown. ClassLoaderServiceImpl will check the SystemClassLoader + // later on. This is especially important for embedded OSGi containers, etc. + super( null ); + } /** - * Load the class and break on first found match. + * Load the class and break on first found match. + * * TODO: Should this throw a different exception or warn if multiple * classes were found? Naming collisions can and do happen in OSGi... */ @@ -93,6 +101,7 @@ public class OsgiClassLoader extends ClassLoader { /** * Load the class and break on first found match. + * * TODO: Should this throw a different exception or warn if multiple * classes were found? Naming collisions can and do happen in OSGi... */