Thread's classloader: Thread.getCurrentThread().getContextClassloader()
Questions tagged [contextclassloader]
40 questions
1
vote
0 answers
How do I have different web applications share same classloader?
We have a suite of applications. As it is now, each application can be deployed individually, or in any combination. The problem is that each of the wars is constructed with its own copy of libraries. Many (LOTS) of which are duplicated in each…

Carlos Bribiescas
- 4,197
- 9
- 35
- 66
1
vote
1 answer
Why can't java use thread context classloader when a method is literally called?
I've written a custom classloader 'JarClassLoader', which itself works ok, since the following test case is green:
public void testJarClassLoader() throws Exception
{
JarClassLoader cl = new JarClassLoader();
…

Utensil
- 17,204
- 1
- 17
- 10
1
vote
2 answers
Loading classes using Spring inside an eclipse OSGi container does not seem to work. Fix?
I am somewhat puzzled about Spring's classloading behavior inside an eclipse OSGi container (which is the basis for the TIBCO ActiveMatrix runtime I am trying to get this running on) and boiled this down to the below simple example.
In it (the…

mmo
- 3,897
- 11
- 42
- 63
1
vote
1 answer
Reload class file in tomcat
I am creating a class file at run time.
I want to replace the existing class file with the updated one in the class loader.
It is similar to hot swapping (e.g. JRebel) which avoids server restart and redeployment.
I found context.xml approach for…

Chetan Shirke
- 896
- 4
- 13
- 35
1
vote
1 answer
How to prevent loading class from jar
I am writing Plugin for some Application. Lets suppose that Application hava library dependency of libA-1.0 and my plugin has similar dependency of libA-2.0. There are different in versions and are not compatible each other (i.e. they have different…

pawel.panasewicz
- 1,831
- 16
- 27
1
vote
3 answers
How can I detect whether the JVM I am running on is using multiple classloaders?
I think my question is self-explanatory. What will be the quickest and most accurate method of determining that the JVM I use is using multiple class loaders? If it does, What care must be taken to ensure that programs run correctly?
EDIT:
I think I…

Phoenix
- 8,695
- 16
- 55
- 88
1
vote
2 answers
Why do we need contexClassLoader
I'm wondering why Java introduced contexClassLoader for threads. I know that it is usualy used by frameworks and application servers which have to dynamically find and load classes.
However I don't understand why Java introduced contexClassLoader…

Paweł Adamski
- 3,285
- 2
- 28
- 48
0
votes
1 answer
Android: after Gradle update to 6.7.1 ClassLoader in JUnit test no longer lists all resources
I need to iterate over specific classes from main package in my android unit test, to check some of their properties.
For this I use standard approach, using ClassLoader:
val classLoader = Thread.currentThread().contextClassLoader
val resources:…

Kurovsky
- 1,081
- 10
- 25
0
votes
1 answer
Oracle leaks threads on when closing Hibernate Sessions with Oracle JDBC driver
We are running a multi classloaders java application using Hibernate:
org.hibernate
hibernate-core
5.4.16.Final
…

Guy Korland
- 9,139
- 14
- 59
- 106
0
votes
1 answer
CompilingClassLoader fun, any ideas how child class loads from different classloader in this case?
createController on line 29 in the below stack trace has clazz.getClasslo
protected Object createController(Injector injector, String controllerClassFullName) {
Class> clazz = classLoader.clazzForName(controllerClassFullName);
return…

Dean Hiller
- 19,235
- 25
- 129
- 212
0
votes
2 answers
Classloader specific properties
We developed an application container that creates a new classloader for each independent application running in the container. When a specific application is invoked, the Thread's context classloader is set appropriately with the application's…

onejigtwojig
- 4,771
- 9
- 32
- 35
0
votes
1 answer
How does the class loader loads an instance of extended class which is declared inside a method? (java.lang.NoClassDefFoundError)
I have a class which have util functions and can be invoked on demand.
Steps to Reproduce :
TestMainWebApp (this project having Dependency of TestMainImp)
TestMainImpl ( this project implements …

Asiya
- 1
- 1
0
votes
0 answers
Java ClassLoader getResources not working with Launcher$AppClassLoader
This code snippet works fine when invoked by websphere server (cl is of type com.ibm.ws.classloader.CompoundClassLoader).
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Enumeration resenum = cl.getResources("/abc.xml");
However,…

Singh
- 23
- 6
0
votes
1 answer
Cannot add web application to built-in Tomcat of @SpringBootApplication with main-thread's context class loader
I am trying to load a war as web application that I ship with my standalone jar. As my @SpringBootApplication is starting up, I extract the war file and copy it to the file system. After that I make a simple tomcat.addWebapp() call which I'd expect…

Stefan Falk
- 23,898
- 50
- 191
- 378
0
votes
0 answers
How can I get the name of caller class when the app goes from activityA to activityB?
I need a function that gets name of caller Class from current activity.
In fact, I want to know, how can I get the name of caller class via getClassLoader function.
By the way, here is my previous question, but I didn't get any acceptable…

MostafaUTD
- 29
- 6