class-loading

JBoss: @Resource not injected when classloader isolation enabled

Hello, JBoss 4.2.3, an application deployed as a ear. Works. Then I enable classloader isolation by adding a loader-repository tag into jboss-app.xml. In multiple beans @Resource TimerService stops being injected and the code throws NullPointerException. What could possibly be the reason of such behavior? I have no clue. Thanks, Artem...

Substitute (override) class implementation at Runtime (Java)

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....

Java: Dynamically Load Multiple Versions of Same Class

I've looked all around and I haven't been able to figure out how to accomplish this. What I'd like to be able to do is to load set of classes, probably all in the same folder. All of which implement the same interface and are the same class, then in my code I'd like to be able to call functions on those classes. Any help you can give, ...

In what order are the different parts of a class initialized when a class is loaded in the JVM?

Imagine a Java class which has most features that you can find in a class. For example: it inherits from another class, implements a couple of interfaces, includes some 'static final' constants, some final constants, some static variables, instance variables, a static block, an unnamed code block (just code in {}), constructors, methods...

Java: How to load Class stored as byte[] into the JVM?

If one has serialized the entire .class file into byte[], and assuming the name of the class is known (passed along with the byte[]), how do you convert byte[] -> Class -> then load it to the JVM so that I could later use it by calling the Class.forName()? NOTE: I'm doing this because I sent the .class over to another host, and the host...

Class.forName not working in Java RMI call

Hi, What effect will Java RMI have on the following line of code? Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Its not working for me in an RMI call. I am new to java and RMI so please elaborate your answer in detail. Edit: //String connect to SQL server String url = "jdbc:sqlserver://" + strServerIPAddress + ":143...

Using spring beans from other modules?

I imagine this is simple - but I can't find the right combination of search terms to get an answer. If I have a multi-module application, how do I get the beans in module A available to the beans in module B. The project setup looks a little like this: project.ear/module-a.jar/resources/beans.xml project.ear/module-a.jar/java/foo/bar.c...

Websphere Classloading

We have an application deployed in Websphere application server 7. Its deployed and functioning in various environments. But it gave a method not found exception in one new env. On digging deeper we found that a particular class was present in 2 jars and the class from the "wrong" jar was getting loaded in the new env. i went through the...

Can JBoss 5 application access jars outside the EAR structure

When the jars are packaged within EAR/lib, all works fine, but I cannot use this approach and need to refer to them from the filesystem (maybe using absolute/relative paths) Also adding the jars to the system classpath (using conf/jboss-service.xml) is not an option. I have already defined a scoped classloading using loader-repository ...

Loading a Java class with native code dependency.

I'm writing a program that loads all the classes from a specified folder. Some of the classes are creating objects in static block and these objects in turn are making some native calls during their creation. Since I do not have the native library I'm seeing a java.lang.UnsatisfiedLinkError Here is a example scenario. Class A extend...

Loading partial entities with Linq to Entities

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 c...

RMI interface loading

Hi Guys. Have a question related to how RMI loads the interface classes. So here is my set up: An interface that defines the operation that the rmi server performs. Common public interface Computable<T> extends Remote{ public AnalyticalServiceOutput<T> compute(Request request) throws RemoteException; } Server Computable<Map<S...

migration to JBoss 5.1 - Failed to create a new SAX parser

I am trying to deploy my application (packed in .war file) that work properly on JBoss 4.2.3 to JBoss 5.1 (using java 5). Currently during deployment time I see in the server.log the error: ... Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser ... Caused by: java.lang.ClassCastE...

BIRT 2.5 deployed with Xerces jar in WEB-INF/lib throws NullPointerException

Hi, so I am having pretty much exactly the same problem as what someone else has described here: birt-exchange. I have integrated BIRT with my existing web application that requires the xerces jar (mine is version 2.5) and the following exception is thrown when I attempt to view the report: java.lang.NullPointerException at org.ecl...

Using a variable to dynamically load a class.

I have decided to use the singleton pattern for my application. It makes the most sense to me. However, just when I feel like I have made some progress I run into another wall. I have a load function. The load function does the following. Check if class has been previously loaded. - If so - return $class::get_instance(); - Otherwise -...

Get bytes for a class that was generated at runtime

I am working with a Java framework that generates some (proxy) classes at runtime, using a custom ClassLoader. I would like to get for any such class that the custom ClassLoader returns from loadClass(..) the raw byte array that corresponds to this class. Is this possible? I know that if a class exists as a resource then you can use an i...

What do people use class loading for?

So, every Java text book talks about how flexible Java is since it can load classes at run time. Just cobble together a string and give it to Class.forName(), and catch the ClassNotFoundException and handle it. So much for the theory. Can you give examples of how you've been using Java class loading to achieve a feature which otherwise...

Implementing a filtering class loader

We are extending our java application to support plugins. Part of that includes keeping plugins isolated from our own classes, thus each plugin will live in it's own class loader. We also plan on giving the plugins a java framework to work with, thus it'll have to be exposed to the plugins. This java framework also contains classes that...

Differences between NoClassDefFoundError and ClassNotFoundException?

NoClassDefFoundError extends LinkageError which in turns extends Error. Javadoc for Error class states: An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Class loading methods like Class.forName() only declares ClassNotFoundException in throws cla...

Rails automatic class loading

Rails has a feature where models, controllers, views, libraries, etc. are automatically loaded when they are needed. This is especially helpful in development mode, where they get automatically reloaded as well. How do I tell Rails to perform automatic loading somewhere it doesn't expect to load files? Say, I create a folder app/addons ...