I have a webapplication where i am serializing an object to XML using XMLEncoder ..The objects written to that are classes which are from the app server classpath and from jars attched by the user in some custom folder ...
But while using XMLDecoder , i need the user classes also in the current classloader so that all the classes will be read properly
I tried using Thread.currentThread().setContextClassLoader(urlLoader);
where urlloader is the loader which has loaded the User classes , but in this case its reading only user classes , not the system classes....
Can any one let me know how to read both classes using that Decoder
Originally posted by sreenath reddy: I tried using Thread.currentThread().setContextClassLoader(urlLoader);
Having had a little look at the JDK sources, it seems to me that this is the correct way to tell XMLDecoder which ClassLoader to use.
but in this case its reading only user classes , not the system classes....
I don't understand exactly what you are saying goes wrong. Can you explain carefully?
Is it possible that your "user" ClassLoader doesn't delegate properly to its parent, or doesn't have a parent? Generally, a ClassLoader should see if its parent can load the class, before trying to load it itself.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
A small mistake from my side , while creating a new URL classloader i had done a mistake by not specifying the Parent Class loader (Webapp classloader) , hence it was taking the Sun Classloader as default and was not able to load the class appropriately
Thanks a ton
Seriously Rick? Seriously? You might as well just read this tiny ad: