You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthew Heaton <Ma...@apexlearning.com> on 2000/11/30 23:38:23 UTC

Struts+Weblogic=Problems but this time it looks like it's Struts

I've been trying to get Struts to work on weblogic for many days with little
success because of the failures of Weblogic's part.  Finally tried to deploy
and use it on Weblogic 6.0 Beta 2 and noticed some interesting behavior.  It
deployed fine but when I tried to run the example application I started
getting errors saying that Weblogic could not deserialize the context
attribute (see exact errors at end of mail)  It appears that Weblogic
requires any object that you use as a context attribute on a JSP page must
be serializable.  I went through some of the Struts source and it's trying
to use objects which aren't serializable as JSP page context attributes.
This looks like it may be a shortcoming in the JSP spec because it makes
sense that to support to failover of sessions you would need to be able to
serialize the attributes since the attributes of a PageContext may have the
scope of an entire session.  This is a bug that probably will show up on
many different App Servers that support the failover of Sessions not just
Weblogic and should probably be addressed in Struts even though it hasn't
been directly addressed by the JSP 1.1 or 1.2 specs

<Nov 30, 2000 1:19:37 PM PST> <Error> <HTTP>
<[WebAppServletContext(6802820,struts-example)] Could not deserialize
context attribute ava.io.NotSerializableException:
org.apache.struts.util.MessageResources
        at
java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
        at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
        at
java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
        at
java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
        at
java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
        at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
        at
weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:7
1)
        at
weblogic.servlet.internal.WebAppServletContext.getAttribute(WebAppServletCon
text.java
:207)
        at
weblogic.servlet.jsp.PageContextImpl.getAttribute(PageContextImpl.java:164)
        at
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:230)
        at jsp_servlet._index._jspService(_index.java:105)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:208)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:244)
        at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.jav
a:1107)
        at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1482)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>

-Matt


Re: Struts+Weblogic=Problems but this time it looks like it's Struts

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Matthew Heaton wrote:

> I've been trying to get Struts to work on weblogic for many days with little
> success because of the failures of Weblogic's part.  Finally tried to deploy
> and use it on Weblogic 6.0 Beta 2 and noticed some interesting behavior.  It
> deployed fine but when I tried to run the example application I started
> getting errors saying that Weblogic could not deserialize the context
> attribute (see exact errors at end of mail)  It appears that Weblogic
> requires any object that you use as a context attribute on a JSP page must
> be serializable.  I went through some of the Struts source and it's trying
> to use objects which aren't serializable as JSP page context attributes.
> This looks like it may be a shortcoming in the JSP spec because it makes
> sense that to support to failover of sessions you would need to be able to
> serialize the attributes since the attributes of a PageContext may have the
> scope of an entire session.  This is a bug that probably will show up on
> many different App Servers that support the failover of Sessions not just
> Weblogic and should probably be addressed in Struts even though it hasn't
> been directly addressed by the JSP 1.1 or 1.2 specs

The specification that actually matters in this regard is the servlet spec.  In
Servlet 2.2, it says (p. 37):

    Within an application that is marked as distributable,
    all requests athat are part of that session can only
    be handled on a single VM at any one time.  In addition,
    all objects placed into instances of the HttpSession
    class using the setAttribute or putValue method must
    implement the Serializable interface.  The servlet container
    may throw an IllegalArgumentException if a non serializable
    object is placed in the session.

(There is similar language in Servlet 2.3 pp. 51-52).

In other words, you are only prohibited (by the specs themselves) from storing
non-serializable session attributes if you include a <distributable> element in
the web.xml file -- which the Struts example application does *not* do.  There
is no spec-based prohibition on storing non-serializable attributes if
<distributable> is not set, although an application server environment might
impose such requirements (although you'd think they would throw the
IllegalArgumentException when session.setAttribute() was called, as the text
above suggests :-).

In non-distributed environments, it is quite common to have non-Serializable
things like JDBC connections and result sets, references to open files, and
things like that stored in sessions.  That is why they are not prohibited
outright.

That all being said, I will take a pass through the example application and make
sure it will run in a distributable fashion on servers that support this.
Besides just making the relevant objects Serializable, there are some other
issues that need to be reviewed -- in particular, the way that the
pseudo-database in the example works.

Note that this issue relates *solely* to the Struts example application.  The
only session attribute that the framework itself ever sets is the
java.util.Locale describing the user's current language choice -- and this class
is itself Serializable.

>
> -Matt

Craig McClanahan

Re: Struts+Weblogic=Problems but this time it looks like it's Struts

Posted by David Chisholm <da...@i2.com>.
This is configurable (Servlet 2.2 spec, section 7.7.2) based on whether you
flag your application as distributed or not using the 'distributable'
element in the web.xml file.  If you flag your application as distributable,
then anything placed in the HttpSession has to be Serializable, and the
servlet container is supposed to throw an exception if it's not.
David


----- Original Message -----
From: "Matthew Heaton" <Ma...@apexlearning.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, November 30, 2000 4:38 PM
Subject: Struts+Weblogic=Problems but this time it looks like it's Struts


> I've been trying to get Struts to work on weblogic for many days with
little
> success because of the failures of Weblogic's part.  Finally tried to
deploy
> and use it on Weblogic 6.0 Beta 2 and noticed some interesting behavior.
It
> deployed fine but when I tried to run the example application I started
> getting errors saying that Weblogic could not deserialize the context
> attribute (see exact errors at end of mail)  It appears that Weblogic
> requires any object that you use as a context attribute on a JSP page must
> be serializable.  I went through some of the Struts source and it's trying
> to use objects which aren't serializable as JSP page context attributes.
> This looks like it may be a shortcoming in the JSP spec because it makes
> sense that to support to failover of sessions you would need to be able to
> serialize the attributes since the attributes of a PageContext may have
the
> scope of an entire session.  This is a bug that probably will show up on
> many different App Servers that support the failover of Sessions not just
> Weblogic and should probably be addressed in Struts even though it hasn't
> been directly addressed by the JSP 1.1 or 1.2 specs
>
> <Nov 30, 2000 1:19:37 PM PST> <Error> <HTTP>
> <[WebAppServletContext(6802820,struts-example)] Could not deserialize
> context attribute ava.io.NotSerializableException:
> org.apache.struts.util.MessageResources
>         at
> java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
>         at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
>         at
> java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
>         at
> java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
>         at
> java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
>         at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
>         at
>
weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:7
> 1)
>         at
>
weblogic.servlet.internal.WebAppServletContext.getAttribute(WebAppServletCon
> text.java
> :207)
>         at
>
weblogic.servlet.jsp.PageContextImpl.getAttribute(PageContextImpl.java:164)
>         at
> org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:230)
>         at jsp_servlet._index._jspService(_index.java:105)
>         at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :208)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :244)
>         at
>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
> ntext.jav
> a:1107)
>         at
>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
> :1482)
>         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> >
>
> -Matt