Hello everyone,
I have been searching this forum for a solution to my problem, but unfortunately couldn't find anything so far. It would be very kind if you could take a look at this.
I am trying to read an object, that I have saved before in a file called "eco.net", in an applet with the readObject() method:
[CODE=java]import java.applet.*;
import java.io.*;
public class TestApplet extends Applet
{
public void init()
{
try{
FileInputStream fis = new FileInputStream ("eco.net");
ObjectInputStre am ois = new ObjectInputStre am(fis);
BioNet bioNet = (BioNet) ois.readObject( );
ois.close();
} catch (IOException e) {
e.printStackTra ce();
} catch (ClassNotFoundE xception e) {
e.printStackTra ce();
}
}
}
[/CODE]
The command-line output of this is:
[CODE=error]java.lang.Stack OverflowError
at java.io.ObjectI nputStream$Bloc kDataInputStrea m.readByte(Obje ctInputStream.j ava:2718)
at java.io.ObjectI nputStream.read Handle(ObjectIn putStream.java: 1428)
at java.io.ObjectI nputStream.read ClassDesc(Objec tInputStream.ja va:1490)
at java.io.ObjectI nputStream.read OrdinaryObject( ObjectInputStre am.java:1732)
at java.io.ObjectI nputStream.read Object0(ObjectI nputStream.java :1329)
at java.io.ObjectI nputStream.read Array(ObjectInp utStream.java:1 667)
at java.io.ObjectI nputStream.read Object0(ObjectI nputStream.java :1323)
at java.io.ObjectI nputStream.defa ultReadFields(O bjectInputStrea m.java:1945)
at java.io.ObjectI nputStream.read SerialData(Obje ctInputStream.j ava:1869)
at java.io.ObjectI nputStream.read OrdinaryObject( ObjectInputStre am.java:1753)
at java.io.ObjectI nputStream.read Object0(ObjectI nputStream.java :1329)
at java.io.ObjectI nputStream.defa ultReadFields(O bjectInputStrea m.java:1945)
...
[/CODE]
These kind of errors continue for more than 1000 lines.
If I try to read the same object in a normal application, this works flawlessly:
[CODE=java]import java.io.*;
public class Test
{
public static void main(String[] args)
{
try{
FileInputStream fis = new FileInputStream ("eco.net");
ObjectInputStre am ois = new ObjectInputStre am(fis);
BioNet bioNet = (BioNet) ois.readObject( );
ois.close();
} catch (IOException e) {
e.printStackTra ce();
} catch (ClassNotFoundE xception e) {
e.printStackTra ce();
}
}
}
[/CODE]
I made sure that the classes I am creating the object "eco.net" from implement the Serializable interface, as I read that this is likely to cause problems.
A bit more information about the object that I am trying to read:
I am trying to create a Java-representation of a biochemical network "BioNet". This uses the classes "Compound" and "Reaction", which are themselves interlinked. Please tell me if it would help you to see the whole code (it is quite a lot, that's why I didn't post it already). The actual writing of the object in a file is done with this code:
[CODE=java]import java.io.*;
public class BuildBioNet {
public static void main(String[] args) {
try {
FileOutputStrea m fos = new FileOutputStrea m("eco.net");
ObjectOutputStr eam oos = new ObjectOutputStr eam(fos);
BioNet eco = new BioNet();
eco.buildFromFi le("ecoInfo.ref ","ecoBioNet.tx t");
oos.writeObject (eco);
// Flush and close the ObjectOutputStr eam.
oos.flush();
oos.close();
} catch (IOException e) {
e.printStackTra ce();
}
}
}
[/CODE]
The file size of "eco.net" is 325kB, if this is of any importance. I am using Java version 1.5.0.
Thank you very very much,any help is appreciated - this problem is driving me mad for days already.
Regards,
Kai
I have been searching this forum for a solution to my problem, but unfortunately couldn't find anything so far. It would be very kind if you could take a look at this.
I am trying to read an object, that I have saved before in a file called "eco.net", in an applet with the readObject() method:
[CODE=java]import java.applet.*;
import java.io.*;
public class TestApplet extends Applet
{
public void init()
{
try{
FileInputStream fis = new FileInputStream ("eco.net");
ObjectInputStre am ois = new ObjectInputStre am(fis);
BioNet bioNet = (BioNet) ois.readObject( );
ois.close();
} catch (IOException e) {
e.printStackTra ce();
} catch (ClassNotFoundE xception e) {
e.printStackTra ce();
}
}
}
[/CODE]
The command-line output of this is:
[CODE=error]java.lang.Stack OverflowError
at java.io.ObjectI nputStream$Bloc kDataInputStrea m.readByte(Obje ctInputStream.j ava:2718)
at java.io.ObjectI nputStream.read Handle(ObjectIn putStream.java: 1428)
at java.io.ObjectI nputStream.read ClassDesc(Objec tInputStream.ja va:1490)
at java.io.ObjectI nputStream.read OrdinaryObject( ObjectInputStre am.java:1732)
at java.io.ObjectI nputStream.read Object0(ObjectI nputStream.java :1329)
at java.io.ObjectI nputStream.read Array(ObjectInp utStream.java:1 667)
at java.io.ObjectI nputStream.read Object0(ObjectI nputStream.java :1323)
at java.io.ObjectI nputStream.defa ultReadFields(O bjectInputStrea m.java:1945)
at java.io.ObjectI nputStream.read SerialData(Obje ctInputStream.j ava:1869)
at java.io.ObjectI nputStream.read OrdinaryObject( ObjectInputStre am.java:1753)
at java.io.ObjectI nputStream.read Object0(ObjectI nputStream.java :1329)
at java.io.ObjectI nputStream.defa ultReadFields(O bjectInputStrea m.java:1945)
...
[/CODE]
These kind of errors continue for more than 1000 lines.
If I try to read the same object in a normal application, this works flawlessly:
[CODE=java]import java.io.*;
public class Test
{
public static void main(String[] args)
{
try{
FileInputStream fis = new FileInputStream ("eco.net");
ObjectInputStre am ois = new ObjectInputStre am(fis);
BioNet bioNet = (BioNet) ois.readObject( );
ois.close();
} catch (IOException e) {
e.printStackTra ce();
} catch (ClassNotFoundE xception e) {
e.printStackTra ce();
}
}
}
[/CODE]
I made sure that the classes I am creating the object "eco.net" from implement the Serializable interface, as I read that this is likely to cause problems.
A bit more information about the object that I am trying to read:
I am trying to create a Java-representation of a biochemical network "BioNet". This uses the classes "Compound" and "Reaction", which are themselves interlinked. Please tell me if it would help you to see the whole code (it is quite a lot, that's why I didn't post it already). The actual writing of the object in a file is done with this code:
[CODE=java]import java.io.*;
public class BuildBioNet {
public static void main(String[] args) {
try {
FileOutputStrea m fos = new FileOutputStrea m("eco.net");
ObjectOutputStr eam oos = new ObjectOutputStr eam(fos);
BioNet eco = new BioNet();
eco.buildFromFi le("ecoInfo.ref ","ecoBioNet.tx t");
oos.writeObject (eco);
// Flush and close the ObjectOutputStr eam.
oos.flush();
oos.close();
} catch (IOException e) {
e.printStackTra ce();
}
}
}
[/CODE]
The file size of "eco.net" is 325kB, if this is of any importance. I am using Java version 1.5.0.
Thank you very very much,any help is appreciated - this problem is driving me mad for days already.
Regards,
Kai
Comment