You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ben <ne...@gmail.com> on 2005/11/10 06:44:42 UTC

FormFile throws Serializable exception in session scope

Hi

Could someone please let me know how to make FormFile work in the
session scope? It always gives me Serializable exception.

I need to use FormFile in session scope.

Thanks,
Ben

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


Re: FormFile throws Serializable exception in session scope

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
The DeferredFileOutputStream used in Commons FileUpload 1.1 is the one from
Commons IO (in FileUpload 1.0 it was a commons FileUpload class) - so if
you're still seeing the same exception referencing
"org.apache.commons.fileupload.DeferredFileOutputStream" then that would
indicate you're still using FileUpload 1.0.

The DeferredFileOutputStream from Commons IO
("org.apache.commons.io.output.DeferredFileOutputStream") is still not
Serializeble - but the instance variable in DiskFileItem has been made
transient. A serialization test was added as part of the fix for the bug you
reference (see http://tinyurl.com/kx77e ) - there could be a problem with
that test, but my first inclination would be that the issue is something in
your deployment.

Niall

----- Original Message ----- 
From: "Joe Germuska" <jo...@germuska.com>
Sent: Wednesday, March 01, 2006 5:11 PM

> Ben <newreaders <at> gmail.com> writes:
>
> >
> > I defined an ActionForm of which it has a FormFile. Prepopulation is
> > not needed for this ActionForm. Configuring this ActionForm is similar
> > to any other forms and here is the exception. I get this exception
> > when I startup/shutdown Tomcat.
>
> ...
>
> > 2005-11-11 09:45:30,000 WARN
> > [ContainerBase.[Catalina].[localhost].[/]] - Cannot serialize session
> > attribute uploadForm for session 0556C80B681118276F9F2B02FEC497E0
> > java.io.NotSerializableException:
> > org.apache.commons.fileupload.DeferredFileOutputStream
>
> DeferredFileOutputStream is not serializable in commons-fileupload before
> version 1.1.
>
> (see http://issues.apache.org/bugzilla/show_bug.cgi?id=32785,
> http://jakarta.apache.org/commons/fileupload/changelog-report.html)
>
> However, having just run into this problem myself, the solution is not as
simple
> as merely changing the commons-fileupload dependency.  I'm just starting
to
> scout this out myself, but I'm wondering if Struts needed to have some
update to
> use the correct classes, or if I'm just blundering and I missed something
else
> more straightforward.
>
> In any case, it appears that CommonsMultipartRequestHandler has not
actually
> been updated to catch up with deprecations in commons-fileupload 1.1, but
I
> haven't yet figured out if that is the reason simply using the newer
> commons-fileupload is still resulting in a problem with the serialization.
>
>
http://struts.apache.org/struts-action/xref/org/apache/struts/upload/CommonsMultipartRequestHandler.html



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


Re: FormFile throws Serializable exception in session scope

Posted by Joe Germuska <jo...@germuska.com>.
Ben <newreaders <at> gmail.com> writes:

> 
> I defined an ActionForm of which it has a FormFile. Prepopulation is
> not needed for this ActionForm. Configuring this ActionForm is similar
> to any other forms and here is the exception. I get this exception
> when I startup/shutdown Tomcat.

...

> 2005-11-11 09:45:30,000 WARN
> [ContainerBase.[Catalina].[localhost].[/]] - Cannot serialize session
> attribute uploadForm for session 0556C80B681118276F9F2B02FEC497E0
> java.io.NotSerializableException:
> org.apache.commons.fileupload.DeferredFileOutputStream

DeferredFileOutputStream is not serializable in commons-fileupload before
version 1.1.

(see http://issues.apache.org/bugzilla/show_bug.cgi?id=32785,
http://jakarta.apache.org/commons/fileupload/changelog-report.html)
 
However, having just run into this problem myself, the solution is not as simple
as merely changing the commons-fileupload dependency.  I'm just starting to
scout this out myself, but I'm wondering if Struts needed to have some update to
use the correct classes, or if I'm just blundering and I missed something else
more straightforward.  

In any case, it appears that CommonsMultipartRequestHandler has not actually
been updated to catch up with deprecations in commons-fileupload 1.1, but I
haven't yet figured out if that is the reason simply using the newer
commons-fileupload is still resulting in a problem with the serialization.
 
http://struts.apache.org/struts-action/xref/org/apache/struts/upload/CommonsMultipartRequestHandler.html




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


Re: FormFile throws Serializable exception in session scope

Posted by Ben <ne...@gmail.com>.
I defined an ActionForm of which it has a FormFile. Prepopulation is
not needed for this ActionForm. Configuring this ActionForm is similar
to any other forms and here is the exception. I get this exception
when I startup/shutdown Tomcat.

ActionForm:

public class UploadForm extends ActionForm {
protected String fileName;
protected FormFile file;

public getFileName() { return fileName; }
public void setFileName(String fileName) { this.fileName = fileName; }
public getFile() { return file;}
public void setFile(FormFile file) { this.file = file; }
}

Struts config:

<form-bean name="uploadForm" type="localhost.UploadForm" />

Exception:

2005-11-11 09:45:30,000 WARN
[ContainerBase.[Catalina].[localhost].[/]] - Cannot serialize session
attribute uploadForm for session 0556C80B681118276F9F2B02FEC497E0
java.io.NotSerializableException:
org.apache.commons.fileupload.DeferredFileOutputStream
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
	at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1445)
	at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:920)
	at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:516)
	at org.apache.catalina.session.StandardManager.unload(StandardManager.java:462)
	at org.apache.catalina.session.StandardManager.stop(StandardManager.java:664)
	at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4255)
	at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:892)
	at org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:1143)
	at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:1115)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:313)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1053)
	at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1065)
	at org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:447)
	at org.apache.catalina.core.StandardService.stop(StandardService.java:512)
	at org.apache.catalina.core.StandardServer.stop(StandardServer.java:717)
	at org.apache.catalina.startup.Catalina.stop(Catalina.java:586)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:561)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)



Thanks,
Ben



On 11/11/05, Laurie Harper <la...@holoweb.net> wrote:
> Ben wrote:
> > Hi
> >
> > Could someone please let me know how to make FormFile work in the
> > session scope? It always gives me Serializable exception.
> >
> > I need to use FormFile in session scope.
>
> FormFile is an interface, so I assume it's the particular implementation
> you're working with that's failing to serialize. How have you configured
> your action form in struts-config.xml, how are you populating it, and
> what is the full trace of the exception you're getting?
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: FormFile throws Serializable exception in session scope

Posted by Laurie Harper <la...@holoweb.net>.
Ben wrote:
> Hi
> 
> Could someone please let me know how to make FormFile work in the
> session scope? It always gives me Serializable exception.
> 
> I need to use FormFile in session scope.

FormFile is an interface, so I assume it's the particular implementation 
you're working with that's failing to serialize. How have you configured 
your action form in struts-config.xml, how are you populating it, and 
what is the full trace of the exception you're getting?

L.


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