apache apachecon app apple asf atom atomprotocol atompub barcamprdu blogapps blogging businessblogging conferences family feeds foss general glassfish google humor ibm java javaone links linux mac microsoft movies music netbeans opensocial opensource photos politics rest roller rome rss socialnetworking socialsite socialsoftware sun triangle trianglebloggers vacation webdev webservices wiki


Tuesday Nov 11, 2003

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?

Roller presentation at the GatorJUG.

Mike Levin This month we'll learn about Roller, the open-source weblog. Written entirely in Java, Roller uses many design patterns and java components and has a fascinating architecture. Pizza and refreshments will be served. ...Welcome to the Gator JUG in sunny Gainesville, Florida.
I've been working on my own Roller presentation, now Mike has beat me to the punch.

This work is licensed under a Creative Commons License.
Copyright 2002-2007, David M Johnson (dave.johnson at rollerweblogger.org)

This is a personal weblog, I do not speak for my employer.