Robert,

I see the problem and I believe there is a simple
solution. Abstractly, the object serialization test is
composed of two parts, a serialization part and a
deserilization part. In principle, performing each
part of the test entirely in a single object loaded by
different classloaders should do the trick. 

I am attaching here a very simple setup which
illustrates the point. HTH, Ceki


--- Robert Bushman <[EMAIL PROTECTED]> wrote:
> Good pointer on the dual classLoaders, and I'm
> stuck again.
> 
> 
> First I tried just calling
> ObjectInputStream.readObject(),
> and it threw:
> java.lang.ClassNotFoundException:
> org.apache.log4j.spi.LoggingEvent
> 
> This is because ObjectInputStream doesn't know
> to use JarClassLoader, and log4j.jar is no longer
> in my classpath.
> 
> 
> Next I tried dynamically loading ObjectInputStream
> using
> the same JarClassLoader that has a reference to the
> new log4j.jar. On calling ois.readObject() I still
> get:
> java.lang.ClassNotFoundException:
> org.apache.log4j.spi.LoggingEvent
> 
> This is because JarClassLoader is still delegating
> the
> loading to the root ClassLoader
> (java.io.ObjectInputStream
> is not in log4j.jar), which leaves ObjectInputStream
> with a reference to root ClassLoader, instead of
> the JarClassLoader.
> 
> 
> So I altered JarClassLoader to also look in rt.jar
> (the Sun jar that includes all the stock packages).
> This should leave ObjectInputStream with a reference
> to the JarClassLoader as it's ClassLoader.
> This fails before JarClassLoader can even return
> the O.I.S. Class definition. It throws:
> java.lang.SecurityException: Prohibited package
> name: java.io
> 
> Which is the same problem as when I first started on
> this with java.io.LoggingEventInputStream
> 
> 
> Once again I feel I have reached an impasse. Any
> ideas?
> 
> 
> BTW, I already tried LoggingEvent.readObject(
> ObjectInputStream ),
> which throws:
> java.io.NotActiveException: defaultReadObject
>       at java.io.ObjectInputStream.readFields
> 
> Presumeably because ObjectInputStream does something
> to initialize the stream before it calls
> targetClass.readObject().
> 
> 
>
-------------------------------------------------------------------
>   Who owns your data?
>     Proprietary protocols and file formats are
> dangerous.
>
-------------------------------------------------------------------
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

Attachment: ser.zip
Description: ser.zip

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to