Re: Serailization gives me null pointer exception. Why?
Sunday, September 15, 2002 08:23 AM
When it comes to NullPointers, it's usually a safe bet that the problem is an application specific problem. Something you think is an instantiated object is actually null. As such, it's normally not possible to answer a question that amounts to "something is null, what's wrong?".
I'd suggest you at least post the stack trace when you run into RuntimeExceptions like this.
To solve this yourself though, try making a *much* simpler example than your application and see what happens. That is, make an object with one String field, and try to serialize / deserialize it. This serves two purposes. First, if your test object is successful, you can slowly make it look like your complicated example. At some point, you'll change something which brings back the NullPointer... there's your bug. On the hand, if the very simple test breaks, then you have a great set of code to provide in your post as a way to reproduce the problem. This will go much farther toward getting help (besides being a good demonstration that you have put in effort yourself trying to fix the problem).
Hope this helps.
Oh yeah... the simple case you create will also serve as an excellent test case, so you can ensure this bug doesn't crop up again as you change your code.