File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Session attribute being removed when not serializable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session attribute being removed when not serializable" Watch "Session attribute being removed when not serializable" New topic
Author

Session attribute being removed when not serializable

marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

Hi

This is a confusing problem for me that started after changing IDE from Netbeans 6.8 to 7.0.1, and after some refactoring. I have tested a lot and have managed to pin it down a bit.

The problem is that a key session attribute is removed from the session after a file is written. Through using listeners I have found the following:

1. The following version of the attribute is removed after the FileWriter is instansiated.

but this serializable version does not get removed

2. When using the non serialized version of the the above, the attribute is removed when the following code is called

but not when this code is called instead


perhaps it's a memory problem.

Anybody any ideas???

Thanks

Marten

Below is a stack trace on an exception thrown and caught when the attribute is removed


when in doubt put it in parenthesis and stick a dollar sign in front of it, only good can come from this.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
Since a servlet container is allowed to serialize a session any time it wants to, you should never rely on a non serializable attribute being maintained.

Bill
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

Thanks Bill,

I now understand that, I will change my design.

Cheers

Marten
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

OK, so I have changed the design so that only serializable attributes are added to the session, but I still seem to have an underlying problem with the context being destroyed; seemingly randomly.

I get the stack trace below. It seems that the reason that my non serializable attribute problem manifested now was because of some other reason, probably related to changing my IDE.

Any ideas on what this stack trace may means?

Thanks

Marten

marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

OK, so this was an Netbeans IDE - Subversion interaction problem.

I was writting myfiles to inside my WEB_INF folder which I can see in my IDE and is version controlled.

When I write my files to a filepath outside of the application path it all works fine. This problem only started happening when I changed to Netbeans 7.0.1.

There is nothing like problem to show you the world.

Cheers

 
 
subject: Session attribute being removed when not serializable
 
Similar Threads
Getting ClassCastException
Help with java.lang.OutOfMemoryError: Java heap space
Module Cannot be Deployed
Issue caused by distributable tag on web.xml on JBOSS
a application responds very slow