permaculture playing cards*
The moose likes Java in General and the fly likes Classloader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Classloader" Watch "Classloader" New topic
Author

Classloader

karl koch
Ranch Hand

Joined: May 25, 2001
Posts: 388
hi everybody
im writing a classloader that loads the classbytes from a DB.
when i instantiate classes using this classloader, then i get java.lang.ClassCastException.
here is what i do: i overwrite the findClass method to load bytes from DB, then call defineClass and return this class. the bytes i retrieve from DB are correct (same as class file in file system)
is there anything else im supposed to do ?
what is definePackage for ? what are all the parameters in definePackage ?
thanks
k
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
IMHO,
whatever you have done is just fine. I don't think you need to be bothered about other methods in java.lang.ClassLoader.
did you try printing out the class name after loading it?
classObj.getName() --> what does it print?
has this class been already loaded by some other class loader(the System class loader?) before
And you are trying to load it again using your custom class loader.
The cast then tends to fail in such cases.
It w'd be nice if you could elaborate the problem a bit. We c'd all learn from it!
 
wood burning stoves
 
subject: Classloader
 
Similar Threads
How to find the size of .class file using java program with out using .IO package?
Q: EJB must not define class in package
package and class question
Detect presence of class file in JAR...
Defining a class in a package