EUR-FREAKING-EKA!
So, the moral of the story is, don't try to deserialize a Java SDK object in Java 1.4.2 if the aforementioned object was serialized in Java 5.0. And what's the story? Well, if the first sentence didn't make any sense to you, then you probably don't care what the story is.
So I've been wracking my brain the better part of a day trying to figure out why I've been getting the Java exception StreamCorruptedException in a code fragment that is attempting to deserialize an object. The object exists in a pre-existing file (i.e., it's not created during the execution of the program). The only "extended" information that stack trace was telling me was that it was getting an I/O error. I've been debugging, trying to work around it, blowing away the file and re-creating it, etc. etc. It just didn't make any sense to me. I've been running other applications which use this same piece of code that was blowing up. In fact, the new code I was working with was basically extending the main class of one of those old programs, to simplify (at least that was the plan) testing some new code I was writing. So it should friggin work!
Long story short, what I finally realized was that I was trying to run this new program in my IDE, and the IDE was still configured to use JDK 1.4.2 (oops). As I mentioned above, the object serialization occurred outside of the IDE, separate from the execution of the failing program. It was created in an Ant build script, which was set up to use JDK 5. Apparently, this is a "bad thing". I'm guessing the underlying object changed between the two JDK versions. Of course, the reason the other programs were working just fine was that I was still running them from the Ant script, not directly from the IDE. Doh!
The frustrating thing is that the exception didn't give any indication of the actual cause, i.e. incompatible versioning. I've seen that in other instances where you try to deserialize an object that was created with a different version of that object. But all the exception told me was that it was encountering an I/O error reading the file. This is reason number 4,831,691,227 why I hate computers.
So I've been wracking my brain the better part of a day trying to figure out why I've been getting the Java exception StreamCorruptedException in a code fragment that is attempting to deserialize an object. The object exists in a pre-existing file (i.e., it's not created during the execution of the program). The only "extended" information that stack trace was telling me was that it was getting an I/O error. I've been debugging, trying to work around it, blowing away the file and re-creating it, etc. etc. It just didn't make any sense to me. I've been running other applications which use this same piece of code that was blowing up. In fact, the new code I was working with was basically extending the main class of one of those old programs, to simplify (at least that was the plan) testing some new code I was writing. So it should friggin work!
Long story short, what I finally realized was that I was trying to run this new program in my IDE, and the IDE was still configured to use JDK 1.4.2 (oops). As I mentioned above, the object serialization occurred outside of the IDE, separate from the execution of the failing program. It was created in an Ant build script, which was set up to use JDK 5. Apparently, this is a "bad thing". I'm guessing the underlying object changed between the two JDK versions. Of course, the reason the other programs were working just fine was that I was still running them from the Ant script, not directly from the IDE. Doh!
The frustrating thing is that the exception didn't give any indication of the actual cause, i.e. incompatible versioning. I've seen that in other instances where you try to deserialize an object that was created with a different version of that object. But all the exception told me was that it was encountering an I/O error reading the file. This is reason number 4,831,691,227 why I hate computers.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home