This is an automated email from the ASF dual-hosted git repository.
jlmonteiro pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/main by this push:
new 9ad77e63e4 TOMEE-3862 Investigate EE classloading approach in
openejb-client with filtering
9ad77e63e4 is described below
commit 9ad77e63e44846b47c67ff05d27d08409d1482c4
Author: Jean-Louis Monteiro <[email protected]>
AuthorDate: Fri Sep 16 17:10:43 2022 +0200
TOMEE-3862 Investigate EE classloading approach in openejb-client with
filtering
---
.../src/main/java/org/apache/openejb/client/Main.java | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git
a/server/openejb-client/src/main/java/org/apache/openejb/client/Main.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/Main.java
index 5ea87d1a3c..99edba2f46 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/Main.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/Main.java
@@ -22,6 +22,7 @@ import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginContext;
import java.io.File;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -59,7 +60,15 @@ public class Main {
if (classLoader == null) {
classLoader = new URLClassLoader(new URL[]{file.toURI().toURL()});
} else {
- classLoader = new URLClassLoader(new URL[]{file.toURI().toURL()},
classLoader);
+ Class<?> classLoaderCLass = URLClassLoader.class;
+ try {
+ classLoaderCLass =
classLoader.loadClass("org.apache.openejb.util.classloader.URLClassLoaderFirst");
+ } catch (final Exception e) {
+ // ignore
+ }
+ final Constructor<ClassLoader> constructor =
+ (Constructor<ClassLoader>)
classLoaderCLass.getConstructor(URL[].class, ClassLoader.class);
+ classLoader = constructor.newInstance(new
URL[]{file.toURI().toURL()}, classLoader);
}
Thread.currentThread().setContextClassLoader(classLoader);