I made it work by putting proper implementation of hashCode(), you can
say how stupid I am for not implementing this in the first place.
Thank you so much for your help. It helps me to understand how to
implement the readObject and writeObject. God bless you.
Adriel
On Tue, 2007-09-18 at 09:37 +0100, Pete Gould wrote:
> Hiya,
>
> If you look at the stack trace, you can see that the error is occuring
> when the hashCode is being calculated for the StudyPageSet:
>
> java.lang.NullPointerException
> at com.voxsant.thinkscan.model.Study.hashCode(Study.java:211)
> at
> com.voxsant.thinkscan.model.StudyPageSet.hashCode(StudyPageSet.java:111)
>
> I believe this is because at the point that StudyPageSet is trying to
> use Study.name as part of its hashCode(), yet name has not yet been
> deserialized.
>
> Therefore I think that you need to supply overridden implementations
> of readObject and writeObject, something like below so that name gets
> loaded before the sets:
>
> private void readObject(ObjectInputStream ois) throws
> ClassNotFoundException, IOException {
> name = (String) ois.readObject();
> studyPageSets = (Set<StudyPageSet>) ois.readObject();
> studyPages = (Set<StudyPages>) ois.readObject();
> }
>
> private void writeObject(ObjectOutputStream oos) throws
> IOException {
> oos.writeObject(this.name);
> oos.writeObject(this.studyPageSets);
> oos.writeObject(this.studyPages);
> }
>
> Obviously these might not be the exact implementations that you want,
> but I think you'll find that this is the approach to take if you need
> the Object model exactly as it currently is.
>
> Cheers,
>
> Pete
>
> On 9/18/07, adriel manalansan <[EMAIL PROTECTED]> wrote:
> I tried to delete the implementation of Serializable in my
> BaseModel,
> but still there is an error in my log file. The log error
>
> ERROR [main] ManagerBase.start(638) | Exception loading
> sessions from persistent storage
> java.lang.NullPointerException
>
> only occurs when I turn off tomcat then restart it again and
> refresh my
> page. the variable Study.name became null but before I
> restarted it has
> a value? How does this error occurs?
>
>
> Thanks,
> Adriel
>
> On Mon, 2007-09-17 at 11:20 -0300, Derek Broughton wrote:
> > adriel manalansan wrote:
> >
> > > Hello everybody,
> > >
> > > I think this is a stupid question but I really cant make
> it work. I am
> > > using appfuse 1.9.4 and webwork. In appfuse, it is default
> that
> > > BaseObject class implements java.io.Serializable. I have a
> superclass
> > > named BaseModel:
> > >
> > > public abstract class BaseModel extends BaseObject
> implements
> > > Serializable {
> >
> > Surely that's a subclass :-)
> >
> > If BaseObject _does_ implement Serializable (it certainly
> does in appfuse
> > 2.0), why do you need BaseModel to do so?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]