classloader

Beanshell will not allow me to add jars to the “default” JRE classloader?

前提是你 提交于 2019-12-10 19:43:11
问题 I have a question about Beanshell that I can't find an answer to anywhere. I am only able to run Beanshell scripts in 1 of 2 ways: Where Classpath is defined before invoking Beanshell and Beanshell uses the JRE default classloader. Where no classpath is defined at all before starting Beanshell and then I use addClassPath() and importCommands() to dynamically build the classpath within Beanshell's classloader. This method does not seem to inherit a jars that were part of the default JRE

when is a class is unloaded [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-10 17:12:15
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Unloading classes in java? public class MyClassLoader extends ClassLoader { private static final int BUFFER_SIZE = 8192; } As per my knowledge a class is loaded by classLoader in JVM when it requires that particlar class . But you please tell me when a class is exactly unloaded ?? 回答1: Classes are eligible to be unloaded if the class loader is GC'ed. So in your example, there are no more references to

Loading partial entities with Linq to Entities

心已入冬 提交于 2019-12-10 14:31:34
问题 I am trying to load a partial entity with Linq to Entities: Dim contacts = From c In My.Context.Contacts _ Select New Contact With { _ .ContactId = c.ContactId, _ .Name = c.Name } I tried it and I get the following NotSupportedException: " The entity or complex type 'CompleteKitchenModel.Contact' cannot be constructed in a LINQ to Entities query. " Thanks 回答1: You'll have to use anonymous type: Dim contacts = From c In My.Context.Contacts _ Select New With { _ .ContactId = c.ContactId, _

java.lang.LinkageError: loader constraint violation

空扰寡人 提交于 2019-12-10 14:08:46
问题 Good day everyone, i have faced with such an issue as linkage error like this: java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.transform.Transformer.transform(Ljavax/xml/transform/Source;Ljavax/xml/transform/Result;)V" the class loader (instance of org/jboss/mx/loading/UnifiedClassLoader3) of the current class, org/richfaces/renderkit/TemplateEncoderRendererBase, and the class loader (instance of <bootloader>) for resolved class, javax/xml/transform

Do security providers cause ClassLoader leaks in Java?

岁酱吖の 提交于 2019-12-10 10:56:12
问题 In my Java EE (Glassfish 3.1.1) application I register a security provider: public static final class XoauthProvider extends Provider { public XoauthProvider() { super("Google Xoauth Provider", 1.0, "Provides the Xoauth experimental SASL Mechanism"); put("SaslClientFactory.XOAUTH", "blah.server.utils.XoauthSaslClientFactory"); } } ... XoauthProvider xoauthProvider = new XoauthProvider(); Security.addProvider(xoauthProvider); I have been receiving following exceptions after redeploys: java

How to load a velocity template into an EJB to be used as a mail template

自作多情 提交于 2019-12-10 10:27:43
问题 I have a Java EE 6 application in which I'd like to use velocity to generate mails from a template. I have a @Named bean which is responsible for loading and filling a particular template. The project is a web application, so I placed my templates into WEB-INF/classes (which btw seems to be rather ugly, but I didn't find a more elegant solution by now) and used the ClasspathResourceLoader to access the files. The configuration is as follows: Properties props = new Properties(); props

classloader总结

霸气de小男生 提交于 2019-12-10 08:09:57
classloader是什么 我的理解classloader就是加载我们的类到内存的类,他主要就是寻找资源,即找到在他能搜索到的路径中,有没有我们的类。有的话就加载到内存。 系统的classloader 系统的classloader有三种 Bootstrap ClassLoader 负责加载java基础类,主要是 %JRE_HOME/lib/ 目录下的rt.jar、resources.jar、charsets.jar和class等 Extension ClassLoader 负责加载java扩展类,主要是 %JRE_HOME/lib/ext 目录下的jar和class App ClassLoader 负责加载当前java应用的classpath中的所有类。 双亲委托机制 系统的classloader实行的是双亲委托机制,双亲委托机制就是在加载类的时候先去父类(此处的父类不是继承里面的父类,双亲委托机制是组合)里查找,如果父类加载到了就算子类的可以在自己的路径下找到,也不能加载。只会从父类中取到加到后的class。这样的好处就是不会重复加载类。 此处只是说系统的classloader,因为你自己写的classloader不一定要遵循这个机制,而且有些情况必须不能遵循,例如tomcat等服务器,加载的时候不会遵循双亲委托(他的classloder是自己实现的),他是优先自己加载

ClassLoader在jvm和tomcat中的区别

≯℡__Kan透↙ 提交于 2019-12-10 08:09:40
发现问题: 前段时间使用ClassLoader类的方法来加载classPath路径下的配置文件,其中用到 getSystemResource (String name) 、 getSystemResourceAsStream (String name) 、 getSystemResources (String name) 这几个方法的时候出现问题。 问题出现在,程序用main方法的方式运行的时候能够正常运行,但是使用tomcat运行的时候就会报空指针异常。 原因: 两种方式运行的ClassLoader加载机制不同,导致了不同的结果。 main方法运行是启动的本地的jdk来加载类,加载机制是: Java默认提供的三个ClassLoader BootStrap ClassLoader :称为启动类加载器,是Java类加载层次中最顶层的类加载器, 负责加载JDK中的核心类库,如:rt.jar、resources.jar、charsets.jar等 ,这个是通过native方法调用C语言实现的。 Extension ClassLoader :称为扩展类加载器,负责加载Java的扩展类库,默认加载JAVA_HOME/jre/lib/ext/目下的所有jar。 App ClassLoader :称为系统类加载器,负责加载应用程序classpath目录下的所有jar和class文件。

Tomcat 6 vs 7 - lib vs shared/lib - jars only?

假如想象 提交于 2019-12-10 04:30:24
问题 When upgrading from Tomcat 6 to Tomcat 7 - we kept a number of files we wanted on the classpath in the $CATALINA_HOME/lib directory on 6 - and it made sense to move these two $CATALINA_HOME/shared/lib on Tomcat 7. What we've found is that the jar files went across ok - but anything that wasn't a jar file - eg an xml file etc was not picked up by the class loaded in the shared/lib directory. When we moved the non-jar files back to the $CATALINA_HOME/lib directory - they loaded into the

Why ContextClassLoader returns path with exclamation character?

半腔热情 提交于 2019-12-10 04:20:46
问题 I try to open file in jar in WEB-INF/lib with Thread.currentThread().getContextClassLoader(); URL url=classLoader.getResource(myconfig); In debugger I can see: jar:file:/C:/apache-tomcat/webapps/mywebapp/WEB-INF/lib/myjarresource.jar! /conf/configuration.xml Why in file path is "!" ? I think for this reason application cannot open this file. How to receive correct path? Thanks. 回答1: It means whatever comes after the ! is inside the JAR file. In case of myjarresource.jar!/conf/configuration