classloader

Is it possible to define a Java ClassLoader that returns completely different classes to the one's requested?

I've tried this, but get a ClassNotFoundException when calling: Class.forName("com.AClass", false, mySpecialLoader) ...

Classloader issues - How to determine which library versions (jar-files) are loaded

Hi there, I've just solved another I-though-I-was-using-this-version-of-a-library-but-apparently-my-app-server-has-already-loaded-an-older-version-of-this-library-issue (sigh). Does anybody know a good way to verify (or monitor) whether your application has access to all the appropriate jar-files, or loaded class-versions? Thanks in a...

Unloading classes in java?

I have a custom class loader so that a desktop application can dynamically start loading classes from an AppServer I need to talk to. We did this since the amount of jars that are required to do this are ridiculous (if we wanted to ship them). We also have version problems if we don't load the classes dynamically at run time from the App...

How to load a jar file at runtime

Hi, I was asked to build a java system that will have the ability to load new code (expantions) while running. How do I re-load a jar file while my code is running? or how do I load a new jar? Obviously, since constant up-time is important, I'd like to add the ability to re-load existing classes while at it (if it does not complicate ...

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 dus not work in this case (and my code does setContextClassLoader(null) ...

Find where java class is loaded from

Does anyone know how to programmaticly find out where the java classloader actually loads the class from? I often work on large projects where the classpath gets very long and manual searching is not really an option. I recently had a problem where the classloader was loading an incorrect version of a class because it was on the clas...

How to deal with LinkageErrors in Java?

Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux. My application, using the Java Plugin Framework, appears unable to convert a dom4j-created XML document to Batik's implementation of the SVG specification. On the console, I learn that an error occurs: Exception in thread "...

Scanning Java annotations at runtime

What is the best way of searching the whole classpath for an annotated class? I'm doing a library and I want to allow the users to annotate their classes, so when the Web application starts I need to scann the whole classpath for certain annotation. Do you know a library or a Java facility to do this? Edit: I'm thinking about somethin...

Problems in ClassLoaders for Long running Tomcat process

Hi, We have hosted our web applications on Tomcat 6.0.18 and experienced the following problem: There are two web apps WebApp1 and WebApp2, both are same system but of different versions. Now the problem is when the tomcat has been running for a week or longer time then sometimes system gives NoClassDefFoundError ! also we got some s...

Overriding application server behaviour for loading jsp-api and servlet-api jars in a packaged web application

I have a project built and packaged with a specific version of jsp-apiand servlet-api jar files. Now I want these jars to be loaded when deploying the web project on any application server for example tomcat, WAS, Weblogic etc. The behaviour I have seen on tomcat is that it gives messages that the packaged version of these apis are not ...

My own classloader?

Here is the problem I'm running into. There's a huge legacy application that runs on java 1.3 and uses external API, say, MyAPI v1.0. The exact implementation of MyAPI 1.0 is located somewhere in the classpath used by the app. There's also a mechanism that allows that app to use external code (some kind of plugin mechanism). Now I have a...

Total number of loaded classes in Glassfish

I have enterprise app with EJB. The total size of the app is 34 meg. When i deploy my app everything is fine but when I redeploy it the number of total loaded classes increases. I'm using visualVM to see this info. So is it how it should be or it's a memory leak. How to solve this problem? Thanks ...

Spring framework - class loader relationship

Hello I am having a problem which is probably related to the Spring / class loader relationship. I will apologise for the verbosity of the question now. I have a number of legacy java applications which were originally written and intended to run within a dedicated JVM. We decided upon examination of the resource usage that efficienci...

Websphere classloader delegation mode

We are using WebSphere 6.1 application server with default classloader delegation mode i.e. PARENT-FIRST. We think about changing it to PARENT-LAST to be able to choose our jsf implementation or our webservices stack. As PARENT-FIRST is the default I wonder how many people switched to PARENT-LAST, and what was the reason to switch, and ...

What reasons have people had to write their own classloader

I was recently asked in an interview about the order in which classloaders are called when a class is loaded. Unfortunately I've never had the need to write my own classloader so at the time was unfamiliar with the intricacies of classloading. This got me wondering, what reasons are their to write your own classloader. So that's my qu...

How to extends the the class java.security.SecureClassLoader?

I want write my own ClassLoader. It should be faster and more dynamic as the default ClassLoader for Applets. But I does not know how I should implements the method: PermissionCollection getPermissions( CodeSource codesource ) The super implementation grant no rights also if there is a valid certificate in the CodeSource. Must I ver...

Java Swing Problem

I have a board with cards in which I have to find matches. I have two variables buttonA and buttonB to keep track of the squares clicked. When they are equal I can remove them from the board by simply adding this code: cards[buttonA].setVisible(false); cards[buttonB].setVisible(false); How can I place the same image on all the button...

Separate DLL and native call in different plugin

I want to separate some DLLs from the associated native JNI classes. Plugins: In plugin A the dlls are placed and loaded when the plugin is loaded. In plugin B (depend on A) the JNI classes are placed which include the native method calls for the DLLs in A. At runtime i get a UnsatisfiedLinkError because the JNI class can't be foun...

Java resource as file

Is there a way in Java to construct a File instance on a resource retrieved from a jar through the classloader? My application uses some files from the jar (default) or from a filesystem directory specified at runtime (user input). I'm looking for a consistent way of a) loading these files as a stream b) listing the files in the user-de...

ClassLoader confusion

I have seen several places that "Class.getClassLoader() returns the ClassLoader used to load that particular class", and therefore, I am stumped by the results of the following example: package test; import java.lang.*; public class ClassLoaders { public static void main(String[] args) throws java.lang.ClassNotFoundException{ ...