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: - import java.applet.*;
-
import java.io.*;
-
-
public class TestApplet extends Applet
-
{
-
public void init()
-
{
-
try{
-
FileInputStream fis = new FileInputStream("eco.net");
-
ObjectInputStream ois = new ObjectInputStream(fis);
-
-
BioNet bioNet = (BioNet) ois.readObject();
-
ois.close();
-
} catch (IOException e) {
-
e.printStackTrace();
-
} catch (ClassNotFoundException e) {
-
e.printStackTrace();
-
}
-
}
-
}
-
The command-line output of this is: - java.lang.StackOverflowError
-
at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2718)
-
at java.io.ObjectInputStream.readHandle(ObjectInputStream.java:1428)
-
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1490)
-
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
-
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
-
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
-
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
-
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
-
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
-
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
-
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
-
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
-
...
-
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: - import java.io.*;
-
-
public class Test
-
{
-
public static void main(String[] args)
-
{
-
try{
-
FileInputStream fis = new FileInputStream("eco.net");
-
ObjectInputStream ois = new ObjectInputStream(fis);
-
-
BioNet bioNet = (BioNet) ois.readObject();
-
ois.close();
-
} catch (IOException e) {
-
e.printStackTrace();
-
} catch (ClassNotFoundException e) {
-
e.printStackTrace();
-
}
-
}
-
}
-
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: - import java.io.*;
-
-
public class BuildBioNet {
-
-
public static void main(String[] args) {
-
try {
-
-
FileOutputStream fos = new FileOutputStream("eco.net");
-
ObjectOutputStream oos = new ObjectOutputStream(fos);
-
-
BioNet eco = new BioNet();
-
eco.buildFromFile("ecoInfo.ref","ecoBioNet.txt");
-
-
oos.writeObject(eco);
-
-
// Flush and close the ObjectOutputStream.
-
oos.flush();
-
oos.close();
-
} catch (IOException e) {
-
e.printStackTrace();
-
}
-
}
-
}
-
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
5 3531
Thank you for your quick answer. I tried raising the maximum memory to 120Mb without effect, I still get the same error message for the applet. My goal is to create a web-tool for external users that work with the biochemical network (a graph creation and manipulation tool), so I would like to keep the applet. It is already working as a standalone application. I have been working with objects of similar size already and it worked without problems, I just can't figure out, why it is not working with this one. Thank you again!
JosAH 11,448
Recognized Expert MVP
Thank you for your quick answer. I tried raising the maximum memory to 120Mb without effect, I still get the same error message for the applet. My goal is to create a web-tool for external users that work with the biochemical network (a graph creation and manipulation tool), so I would like to keep the applet. It is already working as a standalone application. I have been working with objects of similar size already and it worked without problems, I just can't figure out, why it is not working with this one. Thank you again!
Did you also try to increase the stack size? (use the -XMs option). Graphs
are read recursively, i.e. when a node is connected to another node (through an
edge) the ObjectInputStre am calls itself recursively to read that other node.
kind regards,
Jos
Thank you! I already suspected it to be a recursion problem, but couldn't connect it with my network. I will try to change its structure again, so perhaps I can avoid deep recursion. It became a lot clearer to me now.
By the way, changing the stack size was without effect, as well.
Have a nice day still and thank you again!
It worked! I separated the processes 'creating and reading the BioNet' and 'connecting the nodes'. Only after retrieving the "eco.net" object I am establishing the final structure. No StackOverflowEr ror any more.
Thank you all for the final clue and all the help, now I can finally sleep without nightmares of Stacks falling on my head again.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Asad Khan |
last post by:
I have the following method inside I class,
public boolean equals(Object o) {
return (this.equals(o));
}
but when i call this method by "foo.equals(bum)" where foo and bum are some
objects, I get a java.lang.StackOverflowError??
I kinda know why its happening; I think it calls the same equals method and
|
by: SubbaRao Karanam |
last post by:
When I click the Button in Applet , I want it open a Dialog asking for
the excel to open/save etc... It doesnt happen why...
Now it doesnt create the excel file Why....
My Applet code is
------------------------------------------------------------------------------
URL url =new URL("http://localhost:8080/portal/servlet/com.kbs.framework.client.gui.ReportServlet");
|
by: Wayne's World |
last post by:
hi everyone,
i have a big problem, writing a image from my applet to my apache
webserver. i tried three way's of writing that file. every way was
described in forums to solve this problem, but non of them worked and
i don't know why. i'll give you the code of my writing-methods and
describe, what happen when i test them, in order someone of you can
give me a usefull tip, where the problem is.
as inputparameter i give my method a new...
|
by: Rowland |
last post by:
Hi,
I know this question has prob. been asked a million times, but I couldn't
find it in the FAQ, so here goes :
I'm trying to write a Java applet to call a dll that resides on the web
server (running IIS 6). I've written a little test applet that should call a
helloWorld function in the dll, but when I use System.loadLibrary, it gives
me this security warning :
|
by: DKM |
last post by:
Here are the source code files to a Java applet that utilizes
LiveConnect to communicate with Javascript, and the HTML file.
The thing works both in IE 6.0 and FireFox 1.4. but with some problems.
IE crashes when one refreshes the page or leave the page. This happens
only after calling the Java method more than once. It does not crash if
the Java method is called just once and then the page is refreshed.
FireFox does not crash at all...
| |
by: Papa.Coen |
last post by:
After repeatedly calling/using a Dictionary I get a
StackOverflowError. What am I doing wrong?
The situation is as follows:
I have ruler class, this class contains some member variables,
encapsulated properties. SOme of those are calculated when get is
called. These kind of properties are actually Cell classes which have
a Calculation class attached. All Cell properties are stored in a
Dictionary <nameEnum, Cell>
|
by: Richard Maher |
last post by:
Hi,
Can someone please tell me the strategy(ies) used by Java (the Security
Manager or whatever) to determine if a given IP address conforms to the
definition of the codebase from which an applet was retrieved?
For example, if an Applet was loaded from mycluster.mydomain.com, and
"mycluster" was a cluster alias that was using DNS load-balancing (or
round-robin or a.n.other distribution technique) to distribute client
connections among...
|
by: not_a_commie |
last post by:
DataContractSerializer.ReadObject creates an object without calling
any constructors. It doesn't require a parameterless constructor like
all other deserialization implementations I've ever seen or heard
about. That's just weird. How do they do it?
What's more weird, though, is that they don't initialize any fields.
That leads to strange bugs. Of course that's why they have the
OnDeserialized attribute -- you need to initialize your...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |