Hello, thanks for you're attention.
I am deploying the struts-example app on IBM Websphere App Server 4.0 and
receive an IllegalArgumentException - Can't remove attribute from request
scope.
the situation:
I have drilled into the problem and discovered that IBM is using a
significantly different implementation of the class,
org.apache.jasper.runtime.PageContextImpl. Their class alters the logic of
removing attributes using the methods removeAttribute(String s, int i) and
removeAttribute(String s).
I have included the code in the next section of the e-mail. In summary,
using WAS 4.0, attributes are not removed from request scope.
This conflicts most directly with the struts framework class,
org.apache.struts.taglib.html.FormTag. FormTag calls
pageContext.removeAttribute(Constants.BEAN_KEY, PageContext.REQUEST_SCOPE)
and pageContext.removeAttribute(Constants.FORM_KEY,
PageContext.REQUEST_SCOPE) within the doEndTag() method.
Either of these method calls will generate an IllegalArgumentException on
WAS 4.0.
the code (more or less):
org.apache.jasper.runtime.PageContextImpl (note: not the same code as used
in tomcat's implementation...)
public void removeAttribute(String s, int i)
{
switch (i)
{
case PAGE_SCOPE:
pageScopeAttributes.remove(s);
break;
case REQUEST_SCOPE:
throw new IllegalArgumentException("Can't remove Attributes from
request scope");
case SESSION_SCOPE:
if (session == null)
throw new IllegalArgumentException("Can't access
SESSION_SCOPE without an HttpSession");
theSession.removeAttribute(s);
break;
case APPLICATION_SCOPE:
theContext.removeAttribute(s);
break;
}
}
// and ...
public void removeAttribute(String s)
{
pageScopeAttributes.remove(s);
}
// (pageScopeAttributes is a Hashtable of objects stored at Page scope
only!)
a partial solution:
Replacing the removeAttribute(String s, int i) method calls with
removeAttribute(String s) within the struts class, FormTag.doEndTag()
relieves the exception, but on WAS 4.0, it will not remove the attribute!
(in fact, only attributes found in page scope will be removed when the
method, removeAttribute(String s) is called.)
testing results:
Even though the attributes weren't removed from the request scope, those
attributes were replaced by new objects the next time. This didn't seem to
affect the observable behavior of the struts example application.
the question(s):
We really, really want to use struts on WAS 4.0. There seems to be some
logic within struts that relates to "null" attributes.
What are the architectural implications of running an app built upon struts
that will never have it's attributes removed from request scope?
If there are implications, are there ways to work around the problems?
Is it feasible to extend the struts framework to specifically target the
changes noted in WAS 4.0? If so, do you have any recommendations how to go
about doing this?
Thank you very much,
Mark