Questions tagged [contextclassloader]

Thread's classloader: Thread.getCurrentThread().getContextClassloader()

40 questions
58
votes
5 answers

How to get classpath from classloader?

I am using some third party code which when given a '-classpath' command line argument doesnt set the java.class.path, but instead just creates a classloader, adds all the urls for the items on the command line specified classpath to the…
Marcus Mathioudakis
  • 837
  • 1
  • 6
  • 19
19
votes
1 answer

Why Does Clojure Use the Context Classloader by Default?

Why is use-context-classloader set to true by default? Why doesn't Clojure use the current class loader?
mudgen
  • 7,213
  • 11
  • 46
  • 46
11
votes
1 answer

Understanding Thread.currentThread().getContextClassLoader().getResourceAsStream()

I am looking at a code example, and I am not sure what this means. Thread.currentThread().getContextClassLoader() .getResourceAsStream("MyProperty.properties"); It appears that it looking to read a property file but I am not sure where…
Tony
  • 3,319
  • 12
  • 56
  • 71
9
votes
2 answers

Parallel stream doesn't set Thread.contextClassLoader after tomcat upgrade

After tomcat upgrade from 8.5.6 to 8.5.28 parallel stream stopped supplying Threads with contextClassLoader: Because of it Warmer::run can't load classes in it. warmers.parallelStream().forEach(Warmer::run); Do you have any ideas what Tomcat was…
oneat
  • 10,778
  • 16
  • 52
  • 70
7
votes
2 answers

Thread.getContextClassLoader() == null?

Can Thread.getContextClassLoader() be null ? The javadoc is not really clear. Should a library take this case into account ? Update: the reason I asked is that beansbinding.dev.java.net does not work in this case (and my code does…
Tom
  • 55,743
  • 3
  • 27
  • 35
7
votes
1 answer

How can I safely solve this Java context classloader problem?

One and only one of my hundreds of users has trouble starting my Java desktop app. It only starts for him about one-third of the time. The other two-thirds of the time a NullPointerException is thrown at startup: Exception in thread…
Steve McLeod
  • 51,737
  • 47
  • 128
  • 184
7
votes
1 answer

what class loader is used?

I have several questions regarding to class loaders. Class.forName("class.name"); and .... NotYetLoadedClass cls = new NotYetLoadedClass(); ..... What class loaders will be used in each case? For the first case I assume class loader that was used…
michael nesterenko
  • 14,222
  • 25
  • 114
  • 182
4
votes
2 answers

Custom Tomcat Webapp ClassLoader

I'm trying to implement a custom classloader for tomcat. My first attempt yielded a class cast exception (apparently, tomcat tries to cast my loader to org.apache.catalina.loader.WebappLoader). Fine, I extended WebappLoader and added the…
Jim
  • 2,111
  • 4
  • 25
  • 34
1
vote
1 answer

Custom Annotation Scanning Under Geronimo with Tomcat container

How do we get access to the jars that are in “shared/lib” directory of Geronimo Server ? I am using following code to walk through the class loader hierarchy, but unable to get jars libraries found in “shared/lib’” folder. Any idea how I can do…
Bmis13
  • 550
  • 1
  • 8
  • 27
1
vote
0 answers

java.lang.StackOverflowError when java.lang.ClassLoader.loadClass(ClassLoader.java:569)

I have these filling up in the catalina log file causing disk space issues when javaagent is attached. I have no idea from where there are getting triggered. What could be the reason ? java.lang.StackOverflowError at…
1
vote
0 answers

getSystemResource() vs getResource() with relevant ClassLoader

Question one: Is ClassLoader.getSystemResource("img.png"); exactly same as ClassLoader.getSystemClassLoader().getResource("img.png"); and what is the difference (which one to prefer?). I am expecting the answer "don't use either" (inside app…
Code Complete
  • 3,146
  • 1
  • 15
  • 38
1
vote
1 answer

Calling `defineClass` on ClassLoader results in "No matching method found"

I generated a class using ASM and now I'm trying to load this class using the ContextClassLoader: (.defineClass classloader (str pkg "." classname) controllerclass 0 (count controllerclass)) controllerclass is the Byte-array containing the class.…
Daniel Ziltener
  • 647
  • 1
  • 6
  • 21
1
vote
2 answers

Crazy ClassLoader question

The classes: public interface Inter { ...some methods... } public class Impl implements Inter { ...some implementations... } The issue is that for some freaky reason, I have to load the interface Inter with child ClassLoader and the…
m_vitaly
  • 11,856
  • 5
  • 47
  • 63
1
vote
1 answer

Using Esper within OSGi framework

I want to user Esper within an OSGi framework however I'm not sure how the classloading mechanism within OSGi will allow what I need to achieve or even how Esper can be used within OSGi because of it. I'm using Esper 5.3 and upon inspection of the…
D-Dᴙum
  • 7,689
  • 8
  • 58
  • 97
1
vote
0 answers

Dependent jar classes not getting loaded from URLClassloader

I have an application running where I am reading a list of JAR files and loading each jar using URLClassLoader but while loading a Class from one JAR which is referring to another class from different JAR I am getting NoClassDefError. String…
1
2 3