Re: NullPointerException while using ERPersistentSessionStorage
Re: NullPointerException while using ERPersistentSessionStorage
- Subject: Re: NullPointerException while using ERPersistentSessionStorage
- From: Ramsey Gurley <email@hidden>
- Date: Mon, 29 Jul 2013 09:30:39 -0700
This is the result of some general bugginess in EOCustomObject and EOGenericRecord classes. Their serialization is intertwined in such a way as to cause null pointer exceptions.
When you add the persistent session storage framework to your build path, make sure the framework is at the very top of your classpath just under ERExtensions. If it is listed below the EOControl framework, it will not work properly. It might work long enough to appear to be working properly, but you'll definitely get the NPEs at some point :-)
If you still get NPEs after correctly ordering your build path, you may find there is still some bugginess in those two classes. I fixed them so that they work in all the cases I use them, but I have bumped into a couple of cases where the NPE rears its ugly head. Usually I just slightly change the way I'm doing something and it will disappear. For instance, in this case, you may try storing your user in your session.objectStore instead of on an iVar.
If you hit a real blocker, or just feel like working on it, those two classes may still need a couple of tweaks to make serialization of EOs bulletproof. By the time I got to reimplementing them for persistent sessions, I was becoming bored with it :-) Fixing serialization bugs is The Fun™
Ramsey
On Jul 29, 2013, at 5:57 AM, Christoph Wick wrote:
> Hi List,
>
> I was trying to use ERPersistentSessionStorage (looks otherwise very promising, thx Ramsey).
>
> I'm getting a silly NullPointerException (stacktrace below) in an application that was working perfectly before without using ERPersistantSessionStorage. I have no idea how to debug this to get more information.
>
> The problem may come from storing an EO object called PMSUser in the session (basically a user object with name, login, passwd ... PMS=prefix for the project's classes). The code is:
>
> public class Session extends ERXSession {
>
> private PMSUser currentUser = null;
>
> public PMSUser currentUser() {
> return currentUser;
> }
>
> public void setCurrentUser(PMSUser currentUser) {
> this.currentUser = currentUser;
> }
> ...
> }
>
> The page where the error occurs is the one where the user can change his/her personal data using a form like
>
> <wo:form>
> <wo:textfield id="inputGivenName" value = "$session.currentUser.firstName" />
> ...
> <wo:submitButton action="$saveAction" value="save" />
> </wo:form>
>
> but NOT AFTER saving, but directly before rendering the page with the form.
>
> Any ideas? Thanks in advance,
> C.U.CW
> --
>
> Christoph Wick - Diplom Informatiker, Managing Director
> i4innovation GmbH, Professor-Neu-Allee 39, 53225 Bonn, Germany
>
> T +49 2 28 28 62 97 93
> M +49 1 51 22 65 78 90
> F +49 2 28 28 62 97 99
> M email@hidden
> W www.i4innovation.de
>
> Geschäftsführer: Thomas Heep, Christoph Wick
> Sitz der Gesellschaft: Bonn | Amtsgericht Bonn HRB 18548 | USt-IdNr.: DE276502600
>
>
> Jul 29 14:41:01 PMS[65432] WARN NSLog - <er.extensions.appserver.ERXComponentRequestHandler>: Exception occurred while handling request:
> java.lang.NullPointerException
> [2013-7-29 14:41:1 MESZ] <WorkerThread0> java.lang.NullPointerException
> at com.webobjects.eocontrol.EOCustomObject.willReadRelationship(EOCustomObject.java:834)
> at er.extensions.eof.ERXGenericRecord.willReadRelationship(ERXGenericRecord.java:380)
> at com.webobjects.eocontrol._EOMutableKnownKeyDictionary$Initializer$_LazyGenericRecordBinding.valueInObject(_EOMutableKnownKeyDictionary.java:614)
> at er.extensions.eof.ERXGenericRecord$TouchingBinding.valueInObject(ERXGenericRecord.java:209)
> at com.webobjects.eocontrol.EOCustomObject.storedValueForKey(EOCustomObject.java:990)
> at com.webobjects.eocontrol.EOEditingContext._valuesForObject(EOEditingContext.java:790)
> at com.webobjects.eocontrol.EOCustomObject.writeObject(EOCustomObject.java:1125)
> at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
> at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
> at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)
> at java.io.ObjectOutputStream.access$300(ObjectOutputStream.java:161)
> at java.io.ObjectOutputStream$PutFieldImpl.writeFields(ObjectOutputStream.java:1687)
> at java.io.ObjectOutputStream.writeFields(ObjectOutputStream.java:478)
> at com.webobjects.foundation.NSDictionary.writeObject(NSDictionary.java:594)
> at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
> at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
> at com.webobjects.appserver.WOComponent.writeObject(WOComponent.java:314)
> at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
> at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)
> at java.io.ObjectOutputStream.access$300(ObjectOutputStream.java:161)
> at java.io.ObjectOutputStream$PutFieldImpl.writeFields(ObjectOutputStream.java:1687)
> at java.io.ObjectOutputStream.writeFields(ObjectOutputStream.java:478)
> at com.webobjects.foundation.NSDictionary.writeObject(NSDictionary.java:594)
> at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
> at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
> at com.webobjects.appserver.WOComponent.writeObject(WOComponent.java:314)
> at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
> at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
> at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)
> at java.io.ObjectOutputStream.access$300(ObjectOutputStream.java:161)
> at java.io.ObjectOutputStream$PutFieldImpl.writeFields(ObjectOutputStream.java:1687)
> at java.io.ObjectOutputStream.writeFields(ObjectOutputStream.java:478)
> at com.webobjects.foundation.NSDictionary.writeObject(NSDictionary.java:594)
> at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
> at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
> at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
> at er.persistentsessionstorage.model.ERSessionInfo.archiveDataFromSession(ERSessionInfo.java:61)
> at er.persistentsessionstorage.ERPersistentSessionStore.saveSessionForContext(ERPersistentSessionStore.java:46)
> at com.webobjects.appserver.WOSessionStore.checkInSessionForContext(WOSessionStore.java:234)
> at com.webobjects.appserver.WOApplication.saveSessionForContext(WOApplication.java:1892)
> at er.extensions.appserver.ERXApplication.saveSessionForContext(ERXApplication.java:2381)
> at er.extensions.appserver.ERXComponentRequestHandler._dispatchWithPreparedApplication(ERXComponentRequestHandler.java:273)
> at er.extensions.appserver.ERXComponentRequestHandler._handleRequest(ERXComponentRequestHandler.java:302)
> at er.extensions.appserver.ERXComponentRequestHandler.handleRequest(ERXComponentRequestHandler.java:378)
> at com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1687)
> at er.extensions.appserver.ERXApplication.dispatchRequestImmediately(ERXApplication.java:2109)
> at er.extensions.appserver.ERXApplication.dispatchRequest(ERXApplication.java:2074)
> at com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:144)
> at com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:226)
> at java.lang.Thread.run(Thread.java:722)
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden