jQuery in Action, 2nd edition
The moose likes Java in General and the fly likes problems reading an object file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Meteor in Action this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "problems reading an object file" Watch "problems reading an object file" New topic

problems reading an object file

Micah Wedemeyer
Ranch Hand

Joined: Jun 11, 2001
Posts: 68
I keep getting the same exceptions when I attempt to read an object file.
If I'm correctly reading the stack trace, I'm getting an InvalidClassException followed by an IllegalAccessException. I don't know anything about either one.
I'm trying to write a List (an ArrayList) to a file, then read it back in. I write it as a List and attempt to read it (cast) as a List. If anyone has any ideas, please let me know.
java.io.InvalidClassException: com.sun.java.util.collections.AbstractList; IllegalAccessException
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
at com.dailyiowan.ontheline.OnTheLine.readChoiceList(OnTheLine.java)
at com.dailyiowan.ontheline.OnTheLine.doPost(OnTheLine.java)
at com.dailyiowan.ontheline.OnTheLine.doGet(OnTheLine.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:516)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:611)
at com.livesoftware.jrun.JRun.runServlet(JRun.java)
at com.livesoftware.jrun.JRunGeneric.handleConnection(JRunGeneric.java)
at com.livesoftware.jrunwebstar.JRunWebStar.HandleConnection(JRunWebStar.java)
Micah Wedemeyer
Ranch Hand

Joined: Jun 11, 2001
Posts: 68
HA HA, I noticed I am a now ranch hand. More like an outstretched hand begging to be saved!
Micah Wedemeyer
Ranch Hand

Joined: Jun 11, 2001
Posts: 68
anybody? Got any ideas?
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Can you show us the code?

"JavaRanch, where the deer and the Certified play" - David O'Meara
Micah Wedemeyer
Ranch Hand

Joined: Jun 11, 2001
Posts: 68
I've decided not to mess around with writing the List. This seems to be the main problem. Instead, I'll try writing each element of the list to a file. When I read them back in, I'll reconstruct the list manually. Just to make sure, how do I read all objects in a file? Is it like this?
ObjectInputStream in = new ObjectInputStream(new FileInputStream("filename"));
Object o;
List a = new ArrayList();
while (o = in.readObject())
I'm assuming, of course, that when it hits EOF then readObject will return null. Is this a valid assumption?
I agree. Here's the link: http://aspose.com/file-tools
subject: problems reading an object file