Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2004

Tip: Looking for answers? Try searching our database.

Make system classloader aware of a class in jboss

Thread view: 
Adam - 03 Aug 2004 14:36 GMT
I need to make the system class loader know about a class which isn't on the
classpath, but is loaded at run time.
Other classes on the classpath (and hence are loaded by system class loader)
need to be able to use this runtime loaded class. How can I do this?

A bit of background might help: I'm using JBoss with JFreeReport (the latter
library isn't important). The JFreereport classes are on the classpath when
JBoss is started, so everything can see them.
However, JFreeReport cannot see classes which are deployed in jboss as
(presumably) they will have to be loaded using a different class loader.
JFreereport is trying to load a couple of the deployed classes at runtime
using Class.forName(), but cannot find the class, as it is trying to use the
default class loader.
I'm hoping that perhaps there is someway of 'adding' these classes to system
class loader at run time so it will find them, tho I've had no luck so far.

Any ideas?

adam
Oscar kind - 03 Aug 2004 15:51 GMT
> I need to make the system class loader know about a class which isn't on the
> classpath, but is loaded at run time.
> Other classes on the classpath (and hence are loaded by system class loader)
> need to be able to use this runtime loaded class. How can I do this?

You can't. Every classloader has a place it gets its classes from. In
case of the system classloader and similar classloaders, this is a
classpath.

This is also the reason that if you define a data source for an
application, the application server must have the database driver in it's
classpath; not merely the application.

> A bit of background might help: I'm using JBoss with JFreeReport (the latter
> library isn't important). The JFreereport classes are on the classpath when
> JBoss is started, so everything can see them.

Which classloader has JFreeReport? Most application servers have a
classloader for itself (the system classloader), a classloader for all
applications, a classloader for each application and a classloader for
each component of an application (so a web application cannot access the
classes of the EJB component).

> However, JFreeReport cannot see classes which are deployed in jboss as
> (presumably) they will have to be loaded using a different class loader.

Correct.

> JFreereport is trying to load a couple of the deployed classes at runtime
> using Class.forName(), but cannot find the class, as it is trying to use the
> default class loader.

Not entirely. It asks it's own classloader. That classloader searches
its own classpath (or wherever it gets its classes from), and/or asks its
parent classloader (it can also ask its parent first, but I digress).

> I'm hoping that perhaps there is someway of 'adding' these classes to system
> class loader at run time so it will find them, tho I've had no luck so far.

There might be, but I don't know of any classloader inplementations that
allow this. First, you'll have to find out which classloader is being used
by JFreeReport (add your own class to that classpath, and ask that class).
Then, you'll have to find documentation for it, or decompile, and hope
there is a solution. It's a lot of work with little chance of success.

Check out my second paragraph (about data sources and database drivers).
It might give you a more feasible idea.

Signature

Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.