Two things: by the line number I cannot understand where the problem exactly occurs..could you underline it somehow in the source you have posted please? An obvious check: is the UserDetails class implementing the Serializable interface?
Please make an effort to use CODE tags and to cut your code down to the minimum that demonstrates the problem. For instance, your posted code has commented-out lines, which do nothing but confuse the reader.
That said, I think I may be able to help with the issue. I think you write objects to a stream in two distinct stages, using separate ObjectOutputStreams, the second appending to a file that was fully written by the first. Then I think you try to read it in a single stage, using one ObjectInputStream to read both objects. That won't work; the input and output must be done the same way.
However, the posted error is NoSuchMethodError, which is generally an indication of a mis-build. If a required method was not present at compile time, you'd have got a compiler "cannot find symbol" error, not a run-time NoSuchMethodError. This suggests that one of your classes has been modified to be incompatible with another class, but you haven't done enough recompiling to find out.
So you should sort out your build, making sure all classes are compatible with each other, before trying to debug any problem with the serialisation.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Jul 02, 2007
This is the code.
Objective : I dont have a database hence I plan to write the user details in a text file. For the user details I have a class (UserDetails). I also have a class UserList which stores all the details of the users in a ArrayList.
I am trying to append one user at a time when the user enters his details in a jsp and clicks on submit(The jsp code is not pasted here). For that I sensed that the new user detail should get appended at the end which is not happening.
Hence inorder to test I added a main method and tried to enter 2 records simultaneously by putting the append value true. Please refer to this line in the code (ObjectOutput out = new ObjectOutputStream(new FileOutputStream(f,true));.
The error occurs here.
1>Can I append the objects at the end of the file? 2>From the previous post I sensed that reading also would be a problem. Do I need to do anything different to read all the users from the file.