« Roller presentation... | Main | Web continuations,... »

Weblogic: ServletContext attributes MUST be serializable... or not?

I didn't get a good response on the Weblogic forums for this question, so now, dear reader, I bothering you.

If you deploy a simple Servlet/JSP application with an error page on Weblogic 8.1 and your application throws an error, the Servlet Container will save and then restore the contents of your ServletContext. So, if you have any non-serializable ServletContext attributes, you will lose them. (Strange thing is, and this part is definitely a bug, if you deploy the very same application, but without an error page specified in web.xml, then the save and restore will not occur and all of your ServletContext attributes will be preserved.)

This doesn't seem quite right. I realize that the best practice is to only store serializable attributes in your context and in your session, but it is not a requirement of the Servlet specification. If it was a requirement, then setAttribute would take a Serializable rather than just a plain old Object.

Seems to me, non-serializable attributes should only break your application if you try to run in distributed mode. Also, the behavior of ServletContext attributes should be the same regardless of the presence or absence of an error page.

Is this save-and-restore-on-error behavior a bug in Weblogic?

Must context attributes be serializable?

Is there a way to turn off the save-and-restore-on-error behavior on Weblogic?

Comments:

I recently read the sources of Tomcat, Jetty and Resin to find out how they handled persistant sessions and the bottom line is that if you use non serializable objects, you're in the gray area. Tomcat silently discarts them unless you setup logging correctly, Jetty saves nothing to disc, and Resin logs an error (which you can disable). Seems a horrible situation to me :-/

Posted by Geert Bevin on November 13, 2003 at 07:31 PM EST #

Post a Comment:
  • HTML Syntax: NOT allowed

« Roller presentation... | Main | Web continuations,... »

Welcome

This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog

Related entries

Below are the most recent entries in the category Java, some may be related to this entry.