You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/07/01 23:42:08 UTC

DO NOT REPLY [Bug 21244] New: - FormFile implementations should be serializable

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21244>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21244

FormFile implementations should be serializable

           Summary: FormFile implementations should be serializable
           Product: Struts
           Version: Nightly Build
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: File Upload
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: barker@itgssi.com


Side Note: Version for this bug is 1.1 Final which is not currently added to the
Version list

Issue: Placing a FormFile (CommonsMultipartRequestHandler.CommonsFormFile for
example) into the users session will throw an IllegalArgumentException when the
session is serialized to disk or to a clustered machine on J2EE compliant
webservers (Weblogic for example). Note that java.io.File does implement
Serializable.

The issue manifests itself in wizard style applications where the file is first
uploaded and then other web requests, such as creating a parse format, must be
made before the file is manipulated and saved to a database. The natural
implementation of this style of application would be to have a FormFile as one
of the properties of the ActionForm, and save the form in the session. Since it
is not serializable, the app server is allowed to throw an exception.

Work around steps:
1) Use request scoped ActionForm for the file upload.
2) In the Action, write the FormFile to a temporary file created with
File.createTempFile
3) Finally place the File in the session or a session scoped ActionForm


Fix:
Make FormFile implementations, and any other object that would be stored in an
ActionForm implement the java.io.Serializable interface.

Reference material from J2EE1.3 spec Section 6.5 on Servlet 2.3 requirements:

A J2EE distributable web application may place only objects of the following
types into a javax.servlet.http.HttpSession object using the setAttribute or
putValue methods:
� java.io.Serializable
� javax.ejb.EJBObject
� javax.ejb.EJBHome
� javax.transaction.UserTransaction
� a javax.naming.Context object for the java:comp/env context
Web containers may throw an IllegalArgumentException if an object that is
not one of the above types is passed to the setAttribute or putValue methods of
an HttpSession object corresponding to a J2EE distributable session.

Please feel free to contact me regarding this bug.
Ryan Barker

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org