I have an application deployed on Glassfish. Over time the number of loaded classes climbs into the millions and my permgen seems to rise.
To help troubleshoot I added the following to my jvm arguments.
-XX:+PrintGCDetails
-XX:+TraceClassUnloading
-XX:+TraceClassLoading
Now when watching the output, I see the same classes being loaded ...
Hi all,
I am having following lines of code.
sysLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader();
url = sysLoader.getResource("tempFile.txt");
It is giving an weird problem. If I run this from a path where there is no space in the path (Folder names) then it is running fine. But if the path contains any spaces ...
We're running a small JRuby on Rails app under Tomcat 6.0.28 with a Spring-based backend. I've spent some time with the Eclipse Memory Analysis tool and I can definitely tell that instances of the JRubyClassLoader are leaking. I setup our webapp to only use a single JRuby runtime and then I effectively did a hot-deploy to Tomcat by touch...
I have a module that is used by creating a custom class loader. The class loader should therefore be created with the path to the module and also all dependencies.
I'm looking for a way to make it productive to work with this mechanism in both dev and production environments.
I thought the build can generate two files listing all de...
I am trying to load some classes that are common to all the web applications of my ear in a java ee 5 application.
I tried to do this by putting the classes (not jar) in
a) directory called "lib"
b) also specifying in application.xml's
<module><java>lib/common.jar</java></module>
and was not successful by either option a or b...
I am working with a learning management system that runs on JBoss, using JDK 1.5_18.
There is a way to write classes that it will load at runtime, using reflection, in order to react to set events.
When I write the class in POJO the application will successfully find the class.
I am always using the full name of the class, and I ensur...
Hi
I cannot for the life of me find a definition of what the Java VM flag CMSClassUnloadingEnabled actually does, other than some very fuzzy high-level definitions such as "gets rid of your PermGen problems" (which it doesn't, btw).
I have looked on Sun's/Oracle's site, and even the options list doesn't actually say what it does.
Base...
Let's say I've compiled a Groovy script using Groovyc, which has generated one or more .class files in the file system. From a Java application, how do I add those classes to the classpath dynamically in order to load them and call their methods? The goal is to pre-compile Groovy scripts and store them into the database, so evaluation ca...
Conceptually, what am I doing when I'm loading a new Jar? Is URLClassloader the only choice? How should I form those URLs to point to a subdirectory containing more jars.
If anyone is feeling super-generous, some demonstration code to do the following would be really helpful (let's assume "jars/A.jar" contains "myClass" which we want t...
I'm trying to do some JDBC access from JavaScript using the Rhino included in Java 6. But I cannot make the DriverManager find the Driver I want to use.
These two examples should be equivalent:
Java:
public class DbTest {
public static void main(String[] argv) {
java.sql.Connection c = null;
try {
java....
I need to support loading classes from other types of archives(tar.gz,tar.bz2...) and custom types defined by third parties. Do I need to override the 'loadClass' method to achieve that? (Perhaps theres another extension point for doing this? I still want to benefit from all the security checks made by the default class loaders).
...
Any ideas why I am getting this error? (Yes, I looked up the error, and still haven't found a solution)
My error:
Exception in thread "main" java.lang.ClassFormatError: Truncated class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(...
I am trying to create a custom class loader to accomplish the following:
I have a class in package com.company.MyClass
When the class loader is asked to load anything in the following format:
com.company.[additionalPart].MyClass
I'd like the class loader to load com.company.MyClass effectively ignoring the [additionalPart] of the pac...
I wrote a simple Hello World Servlet in Eclipse containing the following in the doGet method of my HelloWorldServlet.java
PrintWriter writer = response.getWriter();
String hello = PropertyLoader.bundle.getProperty("hello");
writer.append(hello);
writer.flush();
PropertyLoader is a simple class in the same package as the Servlet th...
I'm trying to compile and load a class at runtime, without knowing the package of the class. I do know that the class should comply with an interface, and the location of the source, (and hence the class name). I'm trying the following:
/* Compiling source */
File root = new File("scripts");
File sourceFile = new File(root, "Test.java"...
I make a new ClassLoader and make it define a new Class, which means that new class should be in a new namespace, which it is, AFAIK. The strange thing is, when I call Class.getPackage on the new class, it returns the exact same object as returned by calling getPackage on any other class in my main namespace.
According to the JVM spec:
...
I encountered strange behavior of enum type loaded by different class loader. In common library I have enum definition (similar to the following):
enum MyEnumType { VAL_1, VAL_2, VAL_3 };
I have first application which creates following map and registers it as some kind of global in the system (the registration code is only symbolic f...
Hi!
I'm working on a project which includes persistence library (JPA 1.2), EJB 3 and Web presentation layer (JSF). I develop application using Eclipse and application is published on Websphere Application Server Community Edition (Geronimo 2.1.4) through eclipse plugin (but the same thing happens if I publish manually). When publishing ...
If I use
try {
Class.forName("my.package.Foo");
// it exists on the classpath
} catch(ClassNotFoundException e) {
// it does not exist on the classpath
}
the static initializer block of "Foo" is kicked off. Is there a way to determine whether a class "my.package.Foo" is on the classpath without kicking off i...
I would like to write a code internal to my method that print which method/class has invoked it.
(My assumption is that I can't change anything but my method..)
How about other programming languages?
EDIT: Thanks guys, how about JavaScript? python? C++?
...