classloader

Java ServiceLoader explanation

这一生的挚爱 提交于 2019-12-06 06:45:15
问题 I'm trying to understand the Java ServiceLoader concepts, working mechanism and concrete use cases, but find the official documentation too abstract and confusing. First of all, documentation outlines services and service providers . Service is a set of interfaces and abstract classes packaged in a jar archive (API library). Service provider is a set of classes that implements or extends the API, packaged in a distinct jar file (Provider library). So far so good, but then the documentation

How do you share Java Caching System (JCS) resource across multiple EJB

痴心易碎 提交于 2019-12-06 06:42:06
问题 I am using JCS to store the ldap search results which should be shared by multiple EJB. I have created a singleton class to initialize JCS only once but due to EJB's classloader, it's been initialized multiple times with its own copy. so search resources are not shared. How are you guys resolving issue where you need to share the cache across multiple beans? I am looking for cache within JVM. (Not the remote e.g memcached etc.). Glassfish is used as an application server. 回答1: I haven't been

I am getting an “exception in thread ”main“ java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver”

荒凉一梦 提交于 2019-12-06 05:28:58
I have added selenium-standalone.jar & selenium-java.jar but still I am getting the following exception when running the basic program, Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver (wrong name: org/openqa/selenium/Webdriver) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net

Same native library loaded by different class loader

╄→гoц情女王★ 提交于 2019-12-06 05:12:35
Please consider the following scenario: I have two java classes, loaded using different system class loaders. I have a native library that has a queue implemented. Both the classes will load the same library, and add elements to the queue. Is it possible? If so, will the native library implementation be shared across the two classes.? According to the JNI Specification it is not possible. In the JDK, each class loader manages its own set of native libraries. The same JNI native library cannot be loaded into more than one class loader. Doing so causes UnsatisfiedLinkError to be thrown. For

How to separate ear classloader and system classloader in JBoss 6?

倾然丶 夕夏残阳落幕 提交于 2019-12-06 05:09:46
问题 I'm trying to upgrade from JBoss 4.2.1 to JBoss 6. In JBoss 4.2.1, we are manually deploying our application as an exploded war and everything works beautifully. I'm running into problems because the application that I am trying to deploy uses versions of 3rd party libraries that are older than the ones that JBoss 6 now includes by default. The result of this is that I'm getting classloader conflicts all over the place and the application won't even start. At present, I have tried using the

weird behaviour of custom system classloader and MessageDigest

一个人想着一个人 提交于 2019-12-06 04:51:07
问题 I have an application which uses a custom system classloader, set by the Djava.system.class.loader=class parameter. The Application uses RMI. Everything works fine out of eclipse, but if i export a runnable jar, this error happens: Caused by: java.lang.SecurityException: SHA MessageDigest not available at sun.rmi.server.Util.computeMethodHash(Unknown Source) at sun.rmi.server.UnicastServerRef$HashToMethod_Maps.computeValue(Unknown Source) at sun.rmi.server.UnicastServerRef$HashToMethod_Maps

Java custom class loader issue

青春壹個敷衍的年華 提交于 2019-12-06 04:49:33
问题 I'm sending a Class object from client to server side. Every time the server needs to load the Class object sent by the client instead of reusing it by parent delegation model (when it was loaded during the 1st iteration). I'm trying to use a custom class loader on the server side whose loadClass(String) simply calls findClass() instead of checking with parent hierarchy. To achieve this, I'm doing following: Generate byte[] by reading the .class file on the client side as following: Class cl

Stranger things in Android class resolution

本小妞迷上赌 提交于 2019-12-06 04:18:56
问题 I observe quite a few behaviors on Android (I am working on a multidex issue, so I use an emulator in 4.4.4) that leave me speechless about Android class loading: On Android classes are not supposed to be resolved when being loaded by the class loader. But if I create a class: public class M { public Foo m(String i) { switch (i) { case "0": return new Foo(); case "1": return new Foo2(); } return null; } } and debug my app, adding watches: getClass().getClassLoader().findLoadedClass("Foo")

Java7 bootstrap: Checking class without loading?

和自甴很熟 提交于 2019-12-06 04:17:20
When reading the answer to this question , I was wondering how Java7 bootstrap knows about the presence of public static void main(String[] args) method, without running the static initializers ? I have some assumptions on this topic, but some of them is obviously wrong: Java Bootstrap is running in JVM, so it can only use standard JVM features (no native features) - the called class must be on CLASSPATH, for example The standard JVM classloading is done via the normal classloading mechanism (I know it has several steps, I've been playing with classloaders several times) After the class has

Effect of ThreadLocals and side-by-side classloading

时光总嘲笑我的痴心妄想 提交于 2019-12-06 03:22:01
问题 Assuming class A{ private static final ThreadLocal<String> tl = new ThreadLocal<String>(); } If A is loaded in just one classloader on the vm, the value of t1 is obvious. But what happens to t1 if A is loaded side-by-side in two different classloaders ? Will the value be shared for a given thread ? 回答1: Interesting question. As Tom Hawtin - tackline explained, you are basically creating to instances of ThreadLocal<String>() . Now let's have a look at how ThreadLocal actually stores the values