classloader

Loading Spring context with specific classloader

不想你离开。 提交于 2019-11-30 17:47:16
How can I go about loading a Spring context with my own ClassLoader instance? Many Spring Context Loader (for example ClassPathXmlApplicationContext ) are subclass of DefaultResourceLoader . DefaultResourceLoader has a constructor where you can specify the Classloader and also has a setClassLoader method. So it is your task to find a constructor of the Spring Context Loader you need, where you can specify the classloader, or just create it, and then use the set to set the classloader you want. user64141 final ClassLoader properClassLoader = YourClass.class.getClassLoader(); appContext = new

how to share objects between different classloaders?

霸气de小男生 提交于 2019-11-30 17:28:00
I need different classloaders to be able to unload classes. But i need to share objects between them (actually i am getting ClassCastException). So what are the solutions to deal with this?. Thanks Objects from different classloaders can interact with each other through interfaces and classes loaded by a common classloader. One of the primary objectives of using separate classloaders is to prevent exactly the kind of thing that you are trying to do. Security and name conflicts are good reasons for keeping this isolation. Here are a few ways that you can circumvent this isolation. Using the

Problem loading resources while running in Eclipse

心已入冬 提交于 2019-11-30 17:20:11
问题 I'm working on a swing project, using maven2 (from command-line) and eclipse (without maven integration). So, I generate the eclipse project through maven eclipse plugin ( mvn eclipse:eclipse ), import it inside eclipse, and do all my work. My problem is: when I run my app in eclipse (as a Java Application), I can't find none of the resources that are in my src directory. Digging for information on my problem, I get into this answer from another question. So, I compared the output from the

How does Grails handle plugin dependencies

坚强是说给别人听的谎言 提交于 2019-11-30 15:37:55
I'm creating a Grails Plugin as a wrapper for a complex product. This product has a lot of dependencies to other products like hibernate. The issue is, that grails has some same dependencies but with different Versions. E.g. Grails -> hibernate 3.6.7 other product -> hibernate 3.5.6 How does Grails handle the plugin dependencies? Does Grails create an separate ClassLoader for each Plugin? Is it configurable? Thanks in advance! Dónal Grails has a dependency resolution mechanism that resolves conflicts among the dependencies of: Grails itself The Grails application The application's plugins The

Is it possible to have the System ClassLoader load .class files specified at run time?

三世轮回 提交于 2019-11-30 15:25:14
I am writing a static analysis tool for an assignment, it analyses Java bytecode using the ASM library. One of the parts of ASM that we use requires (or at least, appears to require) that the class be loaded from the ClassLoader. We were hoping the tool would be able to analyse .class files without requiring them on the classpath. We already load the .classes from a specified directory at run time and read them in using an InputStream. This is acceptable for ASM in most cases. There are some classes, such as SimpleVerifier , which attempt to load the classes though. Is it possible, under this

Load external library in java web application

帅比萌擦擦* 提交于 2019-11-30 15:22:49
My scenario is the following: I have a WebApp.war that is deployed to a servlet container. This WebApp.war contains in WEB-INF/lib the following libraries: lib_a.jar lib_b.jar I have one other library, say lib_vendor.jar, that I cannot deploy within WebApp/WEB-INF/lib because of licensing issues so I let our customers to copy this library in tomcat/lib after application installation. But since lib_vendor.jar requires lib_a.jar and lib_b.jar that are loaded in the web application class loader, I cannot use lib_vendor.jar. How can I load an external library (not in WEB-INF/lib) in the same

ClassNotFoundException even though the jar containing the class is properly present in the classpath

心不动则不痛 提交于 2019-11-30 15:18:16
问题 I'm configuring a new project in eclipse. my project has many modules including one of them named eas.core. to the buildPath of my eas.core module, i have added a jar file common.jcr.jar containing a class named ContentRepositorySettings , that I'm using into my codes. but on runtime, I'm still getting a ClassNotFoundException as shown below java.lang.NoClassDefFoundError: cm/bao/common/jcr/ContentRepositorySettings at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader

In what order are the different parts of a class initialized when a class is loaded in the JVM?

自作多情 提交于 2019-11-30 14:33:39
Imagine a Java class which has most features that you can find in a class. For example: it inherits from another class, implements a couple of interfaces, includes some 'static final' constants, some final constants, some static variables, instance variables, a static block, an unnamed code block (just code in {}), constructors, methods etc. When the class in question is loaded into the JVM for the first time, in what order are the various portions of the class initialized or loaded into the JVM? What does the call stack in the JVM look like for the loading? Assume that only one classloader is

When is a Java Class loaded?

若如初见. 提交于 2019-11-30 13:48:13
I searched the internet for more than couple of hours and could not reach any conclusion. Recently I decided to use BouncyCastle for SSL but I wanted it to off by default, so that BouncyCastle jar may not be in the class path. private void enableBouncyCastleForSSL() { if (config.isBouncyCastleEnabled()) { Security.insertProviderAt(new BouncyCastleProvider(), 1); } } Even when config is disabled, it was looking for BouncyCastle and it failed with class loader error. java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider I tried moving just the line Security

Why Does Clojure Use the Context Classloader by Default?

旧时模样 提交于 2019-11-30 11:13:34
Why is use-context-classloader set to true by default? Why doesn't Clojure use the current class loader? you can override its behavior by setting clojure.lang.Compiler.LOADER to the class loader ie. final ClassLoader ccl= ClojurePlugin.class.getClassLoader(); clojure.lang.Var.pushThreadBindings(clojure.lang.RT.map( clojure.lang.Compiler.LOADER, ccl) ); try { ... clojure.lang.RT.loadResourceScript( cljFile ); ... }finally{ clojure.lang.RT.popThreadBindings(); } where ClojurePlugin is your class. but when you're using RT class the first time ever(ie. when RT class is loaded) it will use context