ObjectInputStream

View: New views
2 Messages — Rating Filter:   Alert me  

ObjectInputStream

by Adam Bell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm having some problems with ObjectInputStream, using weka again.  If I create a weka.classifiers.functions.MultilayerPerceptron and train it and save it (ObjectOutputStream ) then when I try to load it again(ObjectInputStream) I am getting this error:

Type:java.lang.ClassNotFoundException
Message:weka.classifiers.functions.neural.SigmoidUnit
Source:IKVM.OpenJDK.ClassLibrary
TargetSite:System.Object readObject()
HelpLink:null
TargetSite:System.Object readObject()
HelpLink:null
StackTrace:

   at java.io.ObjectInputStream.readObject()
   at WekaRunner.IO.LoadClassifier(String path) in C:\Documents and Settings\Adam\My Documents\Source\Csharp\General\NV2\Weka\Weka\IO.cs:line 88

It can't find 'weka.classifiers.functions.neural.SigmoidUnit', which exists?

Any idea whats going on here?
Adam


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers

Re: ObjectInputStream

by Jeroen Frijters :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Adam Bell wrote:

> I'm having some problems with ObjectInputStream, using weka again.  If
> I create a weka.classifiers.functions.MultilayerPerceptron and train it
> and save it (ObjectOutputStream ) then when I try to load it
> again(ObjectInputStream) I am getting this error:
>
> Type:java.lang.ClassNotFoundException
> Message:weka.classifiers.functions.neural.SigmoidUnit
> Source:IKVM.OpenJDK.ClassLibrary
> TargetSite:System.Object readObject()
> HelpLink:null
> TargetSite:System.Object readObject()
> HelpLink:null
> StackTrace:
>
>    at java.io.ObjectInputStream.readObject()
>    at WekaRunner.IO.LoadClassifier(String path) in C:\Documents and
> Settings\Adam\My
> Documents\Source\Csharp\General\NV2\Weka\Weka\IO.cs:line 88
>
> It can't find 'weka.classifiers.functions.neural.SigmoidUnit', which
> exists?
>
> Any idea whats going on here?

The class may exist, but the class loader that is used can't find the class. ObjectInputStream uses the first non-null class loader on the call stack and if that happens to be an assembly class loader for an assembly that doesn't reference the weka assembly it won't be able to load from it.

You can either make sure that that assembly has a reference to the weka assembly, or you can override ObjectInputStream.resolveClass() to do resolve the class yourself.

Regards,
Jeroen

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers
LightInTheBox - Buy quality products at wholesale price