classloader

Why can a class not be unloaded without unloading the classloader?

The answer to 'unloading classes in java' says - "The only way that a Class can be unloaded is if the Classloader used is garbage collected." I took a look at the JLS but couldn't understand it Why is this the case? ...

disposing a class loader

I am using a custom class loader which extends URLClassLoader. I load some classes into my custom class loader and perform some task. Once the task is completed i want to dispose of the class loader. I tried doing that by setting the reference to null. But this does not garbage collect the class loader. Is there a way that can help wha...

How do I find resources in a .jar on the classpath?

If I have a collection of resource files in a directory on my classpath, I can enumerate them using ClassLoader.getResources(location). For example if I have /mydir/myresource.properties on the classpath, I can call the classloader's getResources("mydir") and get an enumeration of URLs containing myresource.properties. When I pack up t...

Class unloading in java

When a classloader is garbage collected, are the classes loaded by it unloaded? When the JVM is running is verbose mode, all the loaded classes are o/p. Similarly will the JVM log when it unloads a class? I wrote a custom class loader to test this, but could not see any verbose log for unloading of the classes. CustomClassLoader loader...

cast across classloader?

How can I do this: class Foo { public static Foo get() throws Exception { ClassLoader cl = new URLClassLoader(new URL[]{"foo.jar"}, null); // Foo.class is in foo.jar return (Foo)cl.loadClass("Foo").newInstance(); // fails on class cast } } What I need is for the JVM to consider the Foo instance from cl as if it is an insta...

Shipping jar with default .properties file configurations

Hello, I would like to include a default default.properties file in my .jar library. The idea is to allow the user to override my default is he so desires. I'm having trouble getting the classloader to play nicely with this setup, I've tried to look a at popular jars such as log4j, common-* and others and it seems that no one is implem...

can you load multiple jsf wars in one classloader?

i have 3 war files with JSF installed, 3 faces config, when i make them all load into one class loader that is part of the EAR, it fails on initialization errors. like below. seems like JSF does not like to load multiple times in one classloader, has anyone tried this? to load a EAR with 3 JSF wars? java.lang.NullPointerException at...

Loading from JAR as an InputStream?

Is there a ClassLoader implementation I can use to load classes from an InputStream? I'm trying to load a JAR for which I have an InputStream into a new ClassLoader. ...

Brainstorming: Weird JPA problem, possibly classpath or jar versioning problem???

I'm seeing a weird error message and am looking for some ideas as to what the problem could be. I'm sort of new to using the JPA. I have an application where I'm using Spring's Entity Manager Factory (LocalContainerEntityManagerFactoryBean), EclipseLink as my ORM provider, connected to a MySQL DB and built with Maven. I'm not sure i...

Is there an equivalent to Java's ClassFileTransformer in .NET? (a way to replace a class)

I've been searching for this for quite a while with no luck so far. Is there an equivalent to Java's ClassFileTransformer in .NET? Basically, I want to create a class CustomClassFileTransformer (which in Java would implement the interface ClassFileTransformer) that gets called whenever a class is loaded, and is allowed to tweak it and re...

How to find out all the dependency class names of one class?

I have a big list of classes, a lot of them are not used any more. I know the entries class, I'd like to know all its child classes. I know read class binary would help, wondering whether there is any better way. We are not using class.forName. thanks. ...

Where did this class come from?

How would you go about establishing where a class ( or maybe resource ) has been loaded from? I am trying to work out exactly where a class has been loaded from. Does anyone know if you can find out the following: Which Jar file did the class come from ? What classloader loaded the file? ...

How can I list all classes loaded in a specific class loader

For debug reasons, and curiosity, I wish to list all classes loaded to a specific class loader. Seeing as most methods of a class loader are protected, what is the best way to accomplish what I want? Thanks! ...

Wicket WAR in Jetty: .html files not on classpath

Hi, I deployed a Wicket-based app's .war file to Jetty 7.0.2. The problem is that Jetty copies the classpath to a temp dir, but only copies *.class, so *.html is not available for the classloader and I get the error: WicketMessage: Markup of type 'html' for component 'cz.dynawest.wicket.chat.ChatPage' not found. Copying the war as an ...

spring classloader isolation problem on jboss

Hi, i have two ears deployed on jboss with proper classloaders isolation settings. When seam bean call spring beans which make some queries on database everything works fine, but when spring quartz job bean is invoked and execute tries to execute database queries then there is a problem because spring tries too use hibernate jar from ot...

Removing URL from a URL classloader

Is there any way to remove the URL from a URLClassloader? If suppose we removed the URL from classloader what all possible problems can happen? ...

Trouble implementing Singleton pattern in Tomcat web application due to Class Loader

I'm trying to implement a Singleton in Tomcat 6.24 on Linux with x86_64 OpenJDK 1.6. My application is just a bunch of JSPs and some static content and the JSPs make calls to my Java code. Currently the web.xml just looks like this: <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-insta...

Loading jar file using JCL(JarClassLoader ) : classpath in manifest is ignored ..

I am trying to load jar file using JCL using following code FileInputStream fis = new FileInputStream(new File( "C:\\Users\\sunils\\glassfish-tests\\working\\test.jar") ); JarClassLoader jc = new JarClassLoader( ); jc.add(fis); Class main = jc.loadClass( "highmark.test.Main" ); String[] str={}; ...

Correct use of Classloader (especially in Android)

I read some documentations about classloaders, but im still not sure where and why they are needed. The Android API says: Loads classes and resources from a repository. One or more class loaders are installed at runtime. These are consulted whenever the runtime system needs a specific class that is not yet available in-memo...

Groovy slow to load on first call from Java

I am using Groovy to do some calculations, within an RCP app. When I first click the button that calls the Groovy code, I get a bit of a delay, which doesn't exist on the next and subsequent clicks. Is there any way I can warm the cache (so to speak) ? ...