classloader

Hive: AppClassLoader cannot be cast to URLClassLoader although using JDK8

怎甘沉沦 提交于 2019-12-01 16:29:58
问题 After installing jdk9 I have been seeing this problem: $hive Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/Cellar/hive/2.3.1/libexec/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/Cellar/hadoop/2.8.1/libexec/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl

Override class in java

旧城冷巷雨未停 提交于 2019-12-01 15:05:17
Assume I have a project K K depends lib.jar In lib.jar , there is a class named x.y.z.Foo If i create the same class x.y.z.Foo in K , then in this project when I create a instance of Foo , now will JVM use Foo in K rather than in lib.jar ? And if it's unstable or depends on something , how to make sure that Foo should use K 's version rather than lib.jar ? Java class loading behaviour in a standalone application (at least with no custom classloaders) is stable. Make sure that your k.jar (or path) comes before lib.jar in -cp java arg java -cp k.jar lib.jar ... or add dependencies to /META-INF

java: is there a framework that allows dynamically loading and unloading of jars (but not osgi)?

浪尽此生 提交于 2019-12-01 14:10:33
I want a mechanism that will allow to dynamically load and unload jars as well as calling an activator class in the jar. I don't want to use OSGi because of the cumbersome import/export mechanism. There's a project called the Java Plugin Framework that might be what you're looking for. On their web page it states the project is an attempt to match and extend Eclipse's pre-OSGI plugin architecture. It's a generic framework and isn't tied to SWT/desktop apps. You can use the ClassLoader to dynamically load classes from JAR files. When you have dynamically loaded the class, you can explicitly

Override class in java

為{幸葍}努か 提交于 2019-12-01 13:58:09
问题 Assume I have a project K K depends lib.jar In lib.jar , there is a class named x.y.z.Foo If i create the same class x.y.z.Foo in K , then in this project when I create a instance of Foo , now will JVM use Foo in K rather than in lib.jar ? And if it's unstable or depends on something , how to make sure that Foo should use K 's version rather than lib.jar ? 回答1: Java class loading behaviour in a standalone application (at least with no custom classloaders) is stable. Make sure that your k.jar

Rails / delayed_job - want to load newest version of job class

梦想与她 提交于 2019-12-01 13:02:27
I'm using the delayed_job plugin in Rails to do background processing, and I'm experiencing a hiccup in the 'agile development' I've been experiencing so far in Rails... Usually in rails if I hit an error / want to add some new functionality - I just add some code and refresh the page and the new code runs. With delayed_job, it seems like the job class isn't being reloaded... if a job fails and I go and fix the error and fire the job again, the old code runs again. Is there any way to make delayed_job load the newest version of the job class before invoking it? Just in case this has anything

Define custom system classloader

放肆的年华 提交于 2019-12-01 12:50:15
I'm trying to tell the JVM to use my custom ClassLoader as default ClassLoader This is the VM argument i use to pick my class: -Djava.system.class.loader=JarClassLoader and this is the error i get Error occurred during initialization of VM java.lang.Error: java.lang.NoSuchMethodException: JarClassLoader.<init>(java.lang.ClassLoader) at java.lang.ClassLoader.initSystemClassLoader(Unknown Source) at java.lang.ClassLoader.getSystemClassLoader(Unknown Source) Caused by: java.lang.NoSuchMethodException: JarClassLoader.<init>(java.lang.ClassLoader) at java.lang.Class.getConstructor0(Unknown Source)

Create class with javassist and make it available

孤者浪人 提交于 2019-12-01 12:35:18
I want to do the following: try { Class.forName("MyClass"); } catch(ClassNotFoundException e) { ClassPool pool = ClassPool.getDefault(); CtClass cc = pool.makeClass("MyClass"); Class.forName("MyClass"); } I have tried it, but it doesn't seem to work always... It works in one context, but in the other the same code is crashing on the second "Class.forName("MyClass")"... Calling cc.toClass() always brings the correct class, and have tried cc.writeFile() but it makes no difference. Somehow, in some cases the second Class.forName finds the class, and in other cases it just breaks... Am I missing

Rails / delayed_job - want to load newest version of job class

旧巷老猫 提交于 2019-12-01 12:00:24
问题 I'm using the delayed_job plugin in Rails to do background processing, and I'm experiencing a hiccup in the 'agile development' I've been experiencing so far in Rails... Usually in rails if I hit an error / want to add some new functionality - I just add some code and refresh the page and the new code runs. With delayed_job, it seems like the job class isn't being reloaded... if a job fails and I go and fix the error and fire the job again, the old code runs again. Is there any way to make

A classloader proplem related to spring-boot-devtools

我的梦境 提交于 2019-12-01 11:53:39
问题 Background: Spring boot project, add goods and goods price list Goods: List<GoodsPrice> pricelist; in controller first convert goodsForm to goods(by dozer), then save goods,after saving goods iterate goods price list to populate goodsId. goods.getPriceList().forEach(p -> p.setGoodsId(goods.getId())); When iterate goods price list, throw exception: java.lang.ClassCastException: com.foo.goods.model.GoodsPrice cannot be cast to com.foo.goods.model.GoodsPrice at com.foo.goods.service.GoodsService

log4j properties file bundled into jar in spark app is ignored

丶灬走出姿态 提交于 2019-12-01 11:19:53
问题 I need to read a custom log4j.properties from src/resources and this is not working try{ val inStream :InputStream= className.this.getClass.getClassLoader.getResourceAsStream("log4j.properties"); logCfgProps.load(inStream) } catch { case e: Throwable=> e.printStackTrace() log.error("log.properties file not present") } PropertyConfigurator.configure(logCfgProps) meaning that the log4j bundled in the jar is ignored. I cannot touch the log4j properties in the conf directory in the spark home.