Hi,
I am trying to read database scripts in a Jar file so that I can split up my import.sql files as many times as I see fit.
For instance, I have several projects or modules that provide reference data, so I have a few separate scripts in each project that declares that. Instead of having one large import.sql, my approach was to spli...
I seem to remember some function in the JMX console which allows you to type in a class name, and see the classloaders which loaded it, and from which resources the class was loaded from. Unfortunately, I can't seem to find this. For standalone apps, I've always used the JWhich tool to get this information.
...
I am trying to implement some unit testing for an old framework. I am attempting to mock out the database layer. Unfortunately our framework is a bit old and not quite using best practices so there is no clear separation of concerns. I am bit worried that trying to mock out the database layer might make the JVM load a huge number of clas...
Hi,
my app basically stores a jar file in a "Blob" in mysql and then grabs it through a PHP file.
This is not a problem, because doing:
$ wget http://path/to/php
$ jar tf file.jar
shows the classes perfectly fine. I have tried many things, and the farthest I've gotten is when using ClassLoader.loadClass() when I call newInstance() it...
I want to use JCS (Java Cache System) to cache ldap queries which should be shared by multiple EJB's (class loaders) to avoid the duplicate searches. I have created a singleton wrapper to create only one instance of JCS cache but due to each EJB's having their own class loader, it creates multiple instance of JCS cache so ldap search re...
I use this code snippet to obtain a file as an input stream. The file version.txt is packaged in my app's jar, in the upper-most folder.
InputStream resource = getClass().getClassLoader().getResourceAsStream("version.txt");
This works almost all of the time. But for one user, it's picking up another version.txt, that's not in my jar. ...
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 ...
How can I get the classloader for a osgi bundle in eclipse equinox setup.
Thanks,
Suraj
...
Hi All,
This is a common problem. I'm using 2 libraries A.jar and B.jar and these depend on different versions of the same jar.
Let's say that at runtime I need THIS.x.x.x.jar
MY.jar
-> A.jar -> THIS.1.0.0.jar
-> B.jar -> C.jar -> THIS.5.0.0.jar
I can compile the specific jar (A.jar/B.jar) against its dependency but at r...
I have code using JPA and everything works fine in my development environment and in unit tests. But deploying my modules into the OSGi target environment, I regularly run into the weirdest class loading issues. I really like OSGi, but if I can't fix this once and for all, I'm going to get stark raving mad. And as long as I don't underst...
Hi all,
I have an application which is extendable through java classes that conform to a given interface.
If I run the program from the command line classes, I am able to instantiate the add-on classes using:
Class.forName("myAddon").newInstance();
However if I jar the application (setting the main class correctly), I get a class not...
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.
...
I wanted to use groovy for a little ftp script and found this post http://www.hhhhq.org/blog/2009/05/01/ftp-using-groovy-and-ant/
Since there were several dependencies I wanted to use Grape. All dependencies are resolved and present in the cache. But I can't get Ant to find the optional tasks in the other libs.
It always says
Caught: : ...
Hi all,
Despite warnings to drop my present course of action, I currently see no better way to solve my problem. I must generate Java code at runtime, then compile it, load it and reference it.
Problem is that the generated code imports code that has already been loaded by the system class loader (I suppose) - that is, code present in ...
I'm using rhino via the bean scripting framework to create and configure objects in my java process. Some of the classes used in the scripts need to be loaded dynamically as they won't always be on the standard classpath.
To load these classes I initialize the scripting framework's context factory with a custom class loader that loads t...
Say I'm debugging some weird class loading issues of an application deployed inside of a Java EE app server. By some reason it appears, that I have duplicate jars on the class paths of two classloaders (2 different EAR classloaders), and the classes from namespaces of these class loaders need to colaborate.
So the question is following:...
Is there any way of substituting (overriding) a Java class implementation, which is already loaded by the System class loader by another implementation (available as an array of bytes)?
To illustrate my doubt, follows this code:
public class Main {
public static void main(String ... args) {
Foo foo = new Foo();
foo....
I have two programs: one CLI program, and one GUI. The GUI is a frontend for the CLI, but also a GUI for another program as well.
I am importing the CLI's classes and extending them in the GUI to add GUI elements to the classes, and all is great.
But now I want to split the CLI that I currently have embedded in the GUI (as an include...
Hi all,
I'm using apache POI to extract some data from an excel file.
I need an InputStream to instantiate the POI HSSFWorkbook class HSSFWorkbook wb = new HSSFWorkbook(inputStreamX);
I'm finding differences if I try to construct the InputStream object like
InputStream inputStream = new FileInputStream(new File("/home/xxx/workspace...
The typically method to reference a file contained with a JAR file is to use ClassLoader.getResource. Is there a way to get the contents of a directory within a JAR files (similar to java.io.File.listFiles())? Note that the JAR file is within the classpath and its filename might not be known during runtime.
Basically I have a bunch of n...