apache+tomcat 集群 sturts上传文件 FormFile 序列化问题

这破问题我还找了半天!!!!!!!!!!

错误如下:

严重: Unable to serialize delta request for sessionid [7C207DEBA5350582EFF4321AD3089918]
java.io.NotSerializableException: org.apache.struts.upload.CommonsMultipartRequestHandler$CommonsFormFile
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
    at org.apache.catalina.cluster.session.DeltaRequest$AttributeInfo.writeExternal(DeltaRequest.java:347)
    at org.apache.catalina.cluster.session.DeltaRequest.writeExternal(DeltaRequest.java:264)
    at org.apache.catalina.cluster.session.DeltaManager.unloadDeltaRequest(DeltaManager.java:715)
    at org.apache.catalina.cluster.session.DeltaManager.requestCompleted(DeltaManager.java:1298)
    at org.apache.catalina.cluster.tcp.ReplicationValve.send(ReplicationValve.java:549)
    at org.apache.catalina.cluster.tcp.ReplicationValve.sendMessage(ReplicationValve.java:536)
    at org.apache.catalina.cluster.tcp.ReplicationValve.sendSessionReplicationMessage(ReplicationValve.java:518)
    at org.apache.catalina.cluster.tcp.ReplicationValve.sendReplicationMessage(ReplicationValve.java:428)
    at org.apache.catalina.cluster.tcp.ReplicationValve.invoke(ReplicationValve.java:362)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Thread.java:595)

 

解决办法:

private transient FormFile file = null;

java关键字Transient  :
Java的serialization提供了一种持久化对象实例的机制。当持久化对象时,可能有一个特殊的对象数据成员,我们不想用serialization机制来保存它。为了在一个特定对象的一个域上关闭serialization,可以在这个域前加上关键字transient。transient是Java语言的关键字,用来表示一个域不是该对象串行化的一部分。当一个对象被串行化的时候,transient型变量的值不包括在串行化的表示中,然而非transient型的变量是被包括进去的。 

posted @ 2013-01-19 17:19  天纯蓝  阅读(1231)  评论(0编辑  收藏  举报