Announcement Announcement Module
Collapse
No announcement yet.
Serializing an @Component with a DAO? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Serializing an @Component with a DAO?

    Hello guys!

    I know it will seem like a WAS issue at first but my question is related to Spring in the end so pls bare with me :


    I am a developer for a vendor managed app not a WAS 6.1 admin so I apologize if my questions don't make sense but I will try my best: there is an issue that comes in our prod logs :


    [1/29/12 8:55:58:936 AST] 00000010 WASSession E DatabaseHashMap serializeAppData SESN0040E: Exception caught while trying to serialize session data for subsequent database write.
    [1/29/12 8:55:58:942 AST] 00000010 WASSessionCor E DatabaseHashMap serializeAppData Exception is:
    java.io.NotSerializableException: com.fakegeeks.fakeapps.domain.Organization
    at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1164)
    at java.io.ObjectOutputStream.defaultWriteFields(Obje ctOutputStream.java:1518)
    at java.io.ObjectOutputStream.writeSerialData(ObjectO utputStream.java:1483)
    at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1400)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1158)
    at java.io.ObjectOutputStream.defaultWriteFields(Obje ctOutputStream.java:1518)
    at java.io.ObjectOutputStream.writeSerialData(ObjectO utputStream.java:1483)
    at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1400)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1158)
    at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:330)
    at java.util.Hashtable.writeObject(Hashtable.java:824 )
    at sun.reflect.GeneratedMethodAccessor16.invoke(Unkno wn Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(Object StreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectO utputStream.java:1469)
    at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1400)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1158)
    at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:330)
    at com.ibm.ws.session.store.db.DatabaseHashMap.serial izeAppData(DatabaseHashMap.java:2308)
    at com.ibm.ws.session.store.db.DatabaseHashMap.persis tSession(DatabaseHashMap.java:2107)
    at com.ibm.ws.session.store.common.BackedHashMap.upda teSession(BackedHashMap.java:469)
    at com.ibm.ws.session.store.common.BackedHashMap.put( BackedHashMap.java:543)
    at com.ibm.ws.session.store.common.BackedSession.flus h(BackedSession.java:239)
    at com.ibm.ws.session.store.common.BackedSession.flus h(BackedSession.java:224)
    at com.ibm.ws.session.store.common.BackedHashMap.doTi meBasedWrites(BackedHashMap.java:992)
    at com.ibm.ws.session.store.common.BackedStore.runTim eBasedWrites(BackedStore.java:125)
    at com.ibm.ws.session.WsTBWSessionStorer.alarm(WsTBWS essionStorer.java:118)
    at com.ibm.ejs.util.am._Alarm.run(_Alarm.java:133)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava:1604)

    I looked into the class Organization and is a Spring @Components @Scope("Session").

    Now, What I understand is that websphere is trying to serialize the Session Object "Oraganization" and it is not able to serialize it in DB.

    I dont know why is WAS throwing this error, it could be a WAS issue or Spring so I will try to ask some spring related questions to reduce the possibility that Spring is used incorrectly in the application:

    Now the exception : Why is it happening if its normal for WAS to do persist session in some DB: Organization is I stated a @Scope(Session) scoped Spring @Component . It extends a class that has a class that is purely non serializable in nature, kinda like a DAO. Organization is NOT serializable either nor any of the class that it extends.

    The service is @AutoWired into a parent class that is extended by a class that Organization extends and. So if a certain DAO is @AutoWired to a @Component Can the component still be serialized?

    (Forgot to add: loginDao is not marked with @Service its just a plain class with CRUD operational methods)

    @Component("organization")
    @Scope("session")
    public class Organization extends Profile
    {

    }
    //No @Component or any annotation
    public class Profile
    {

    @Autowired
    private Operations operations;
    }

    @Component("operations")
    public class Operations
    {

    @Autowired
    private User user;

    @Autowired
    private LoginDao logindao

    }
    I will appreciate any info/hint on this
    Thanks in advance.

    Syed..
    Last edited by sarmahdi; Jan 29th, 2012, 05:50 AM. Reason: added a comment
Working...
X