reset password
Author Message
JHautzinger
Posts: 14
Posted 15:24 May 27, 2010 |

My Revision class extends AbstractMessage and my EditRevision controller extends AbstractMessageController.


When I to upload a file, the new revision is created, but no file is uploaded, when I try to get the number of revision attachments I get an error:

 

2010-05-27 15:18:15,520 ERROR ExceptionResolver: failed to lazily initialize a collection of role: csns.model.wiki.Revision.attachments, no session or session was closed
2010-05-27 15:18:15,520 ERROR ExceptionResolver: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: csns.model.wiki.Revision.attachments, no session or session was closed

 

Any help?

JHautzinger
Posts: 14
Posted 19:46 May 27, 2010 |

So I fixed the exception, but the upload is still failing.  Everything runs fine, but when I upload there is no sign of the file anywhere.

alomo
Posts: 70
Posted 21:57 May 27, 2010 |
JHautzinger wrote:

So I fixed the exception, but the upload is still failing.  Everything runs fine, but when I upload there is no sign of the file anywhere.

 

I am stuck on the same problem - revision is created and saved, but attachments - not.

As I understand, the file uploading shall be done by processMessage method on AbstractMessageController.

So we call this method from the onSumbit method. For example, like that:

processMessage( revision, user, request );

However, that method will check if request is instance of MultipartHttpServletRequest. And if it is not, then nothing will be done regarding the file uploading.

Apparently, that method cannot cast the request into MultipartHttpServletRequest. And that is where I stuck completely.

Last edited by alomo at 21:59 May 27, 2010.
JHautzinger
Posts: 14
Posted 21:58 May 27, 2010 |

Exactly, I think what makes it a MultipartHttpServletRequest is that it has basically two parts, the standard request data and extra data, in this case a file.  I believe it is automatically cast to that once the file is picked up.

 

Anyone with this working care to illuminate us on how they did it?

 

Maybe a beer will shed more light on this.

Last edited by JHautzinger at 22:17 May 27, 2010.
katiatkn
Posts: 16
Posted 22:30 May 27, 2010 |

Did you guys added enctype="multipart/form-data" in the <form> tag?
 

<
form:form  commandName="xyz" enctype="multipart/form-data">
....
</form>

Ref: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2

JHautzinger
Posts: 14
Posted 22:32 May 27, 2010 |

Spelled it wrong. Doh!