classloader

getClass().getClassLoader() is null, why?

半世苍凉 提交于 2019-12-28 03:45:07
问题 I've got some code that calls.. x = getClass().getClassLoader(); This returns null though. When I start the same code not from Eclipse, but the command line, it returns a classloader. I can hack the code to do this... if (getClass().getClassLoader() == null) { x = ClassLoader.getSystemClassLoader().getSystemResourceAsStream( loadedPropFileName ); } both are compiled and run with the same JVM. (I'm 99.99% sure). Anyone have any ideas why the first would return null for the classloader? Edit:

What loads the java system classloader?

三世轮回 提交于 2019-12-28 01:49:21
问题 We know that we can override the System classloader with: java -Djava.system.class.loader=com.test.MyClassLoader xxx Then, since com.test.MyClassLoader itself is a class, by whom is it loaded? How do we get the class file of this "meta" classloader? 回答1: From the Javadoc for ClassLoader.getSystemClassLoader: If the system property "java.system.class.loader" is defined when this method is first invoked then the value of that property is taken to be the name of a class that will be returned as

Glassfish unable to location javax.persistence.Persistence in module

半世苍凉 提交于 2019-12-25 18:29:48
问题 I'm facing the same problem as here. I can deploy my application without errors but when I try to view the index page I get the an error with the following root cause: [#|2014-06-02T16:53:37.524+0100|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=18;_ThreadName=Thread-2;|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception java.lang.ClassNotFoundException: javax.persistence.Persistence at java

ClassNotFoundException while loading class in Tomcat using custom ClassLoader

邮差的信 提交于 2019-12-25 16:26:33
问题 I'm using Maven 3.2.3 with an embedded Tomcat. Here is my configuration. server.xml - I've defined the Loader Component within the server.xml's Context Element. The location of the file is outside the classpath under /conf/tomcat .... <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false"> <Context docBase="../../myapp/" path="/myapp"> <Loader loaderClass="com.sample.MyClassLoader" delegate="false"

OSGi GWT org.apache.commons.mail.EmailException

天大地大妈咪最大 提交于 2019-12-25 10:05:13
问题 I have an OSGi application which has a command line interface and a GWT interface. I have a separate bundle that is responsible for sending emails. It uses Apache Commons Email. The email bundle only provides one method for sending email and all of the properties are hard coded at the moment. When I send the email from the command line, it gets a reference to the bundle and sends off the email with no problem. When I send the email from the GWT interface, it gets a reference to the bundle and

Load jar file contained within another jar file not working

谁说我不能喝 提交于 2019-12-25 09:47:30
问题 I've been playing around with loading jar files dynamically and I can't get this to work. I have a jar file (resource.jar) in my source folder of Eclipse so it's in the classpath. I'm trying to get it as a resource to load an applet, add it to a jframe, and run it. This isn't working for some unknown reason to myself. This is the code I'm trying. URL jarURL = getClass().getClassLoader().getResource("resource.jar"); ClassLoader urlLoader = new URLClassLoader(new URL[]{jarURL}); applet =

java - Initial package of class from another directory

耗尽温柔 提交于 2019-12-25 09:02:05
问题 I have some problem how to initial package from class file from another directory File file=new File("D:\\java\\myproject\\Name_pack\\time\\MyClass.class"); URL[] cp = { new File(file.getParent()).toURI().toURL() }; URLClassLoader urlcl = new URLClassLoader(cp); Class cls = urlcl.loadClass(file.getName().replaceAll("\\.class",""); if class file not contain a package, it's working. but it's contains a package, i get some error like this : Exception in thread "AWT-EventQueue-0" java.lang

Dynamic loading and unloading of jar

拜拜、爱过 提交于 2019-12-25 08:57:14
问题 We have a java based (jersey+grizzly) REST Server which exposes calls like foo.com/{game}/rules foo.com/{game}/players foo.com/{game}/matches There can be arbitrary number of games Each game has different implementations for rules, players, matches For historical reasons, we would want separate jars for each game implementation So there is REST Server as and when there is a call like foo.com/tennis/rules we want the REST Server to dynamically load 'tennis' jar. The jar does its operation.

what classloader loads the lib directory of an ear in websphere (or in general)?

家住魔仙堡 提交于 2019-12-25 07:48:53
问题 The documentation on classloaders here ( you have to go through the menus... WebSphere Application Server (Distributed operating systems), Version 8.5 > Developing applications > Developing applications in the full profile environment > Class loading ) say this in regards to class loading order: The bootstrap, extensions, and CLASSPATH class loaders created by the Java virtual machine A WebSphere extensions class loader One or more application module class loaders that load elements of

Java: (Partial) Serialization of classes (not objects!)

烈酒焚心 提交于 2019-12-25 06:55:22
问题 I am currently working on a task to package a component and its dependencies together and makes a stand-alone component out of it that has all needed stuff included. I have the situation that I might have user-defined classes which I need to include in this component, too. I am looking for a way to serialize them in a slim/smart way. These classes have a inheritance hierarchy for instance: FrameWorkSuper -------------- UserSuper UserClass Is there a way to serialize only the User-defined part