Upload component immediate mode problem with same file upload

Using Vaadin 7.1.3 currently but same problem was in earlier versions too.

Upload is in immediate mode.
It works fine for the first time.

But if same file is uploaded again it sometimes hangs up and nothing is happening.
No errors visible.

If you upload some other file it is uploaded.
After that teh original file upload works again.

It is not happening every time but quite often Upload component is not doing anything.
Is there a known bug or can this be handled in some other way?

Our application is checking the file content and gives user an error if content is not OK.
User can edit the file and upload it again.
If still errors user edits file and tries again.

End customer will not be happy if this happens and will complain to us that our application is not working.

Attached is shortened example how Upload is used
13236.java (5.24 KB)

I have not seen this behaviour ( 7.1.0 - 7.1.7 )

But I do notice you dont create a new ByteArrayOutputStream when you receiveUpload , perhaps your byteOutput is not in a good state when the next upload occurs…

upload = new Upload();
        upload.setReceiver(new ContentReceiver());
        upload.addSucceededListener(new Upload.SucceededListener() {
            public void uploadSucceeded(final Upload.SucceededEvent event) {
                fireViewEvent(PaperListViewPresenter.UPLOAD_SUCCEEDED, (ContentReceiver) upload.getReceiver());
public static class ContentReceiver implements Upload.Receiver {

        private java.io.ByteArrayOutputStream uploadOutputStream;
        private String uploadFileName;
        private String uploadMimeType;

        public ByteArrayOutputStream getUploadOutputStream() {
            return uploadOutputStream;

        public void setUploadOutputStream(final ByteArrayOutputStream uploadOutputStream) {
            this.uploadOutputStream = uploadOutputStream;

        public String getUploadFileName() {
            return uploadFileName;

        public void setUploadFileName(final String uploadFileName) {
            this.uploadFileName = uploadFileName;

        public String getUploadMimeType() {
            return uploadMimeType;

        public void setUploadMimeType(final String uploadMimeType) {
            this.uploadMimeType = uploadMimeType;

        public void reset() {
            if (uploadOutputStream != null) {
                try {
                } catch (IOException ex) {
                    Logger.getLogger(PaperListViewImpl.class.getName()).log(Level.SEVERE, null, ex);
            uploadOutputStream = null;
            uploadFileName = null;
            uploadMimeType = null;

        public OutputStream receiveUpload(final String filename, final String mimeType) {
            if (uploadOutputStream != null) {
                try {
                } catch (IOException ex) {
                    Logger.getLogger(PaperListViewImpl.class.getName()).log(Level.SEVERE, null, ex);
            uploadFileName = filename;
            uploadMimeType = mimeType;
            uploadOutputStream = new java.io.ByteArrayOutputStream(10240);
            return uploadOutputStream;

When I received an upload I reset the ContentReceiver te clear the outputStreams.
another option would be to set a new ContentReceiver instance…

BTW , are you using push or not ?

Thanks for quick answer.

New ByteArrayOutputStream is not created due I thought reset() method wouls set it to correct state.
I will try this as soon as I will have time.

I also will try the second thing with the receiver.

I am not using push.


I change the code so that new ByteArrayOutputStream is cretaed and new Reciver is created for every upload.
It did not solve the problem.

If I use set immediate mode to false there is no problem.
Same file can be uploaded as many times as you want.

In immediate mode true it hangs up.

What Servlet container + browsers ?

I have not had any reports from the end-users that the upload screens have problems and I have not seen any , but it is possible that you have a combination that causes some problem …

Also it might be advised to update to the latest 7.1.7…

I am having the exact same problem. In immediate mode, if you select the same file twice it does not trigger the upload. No exception nothing, it just does not do anything. If you select another file it works as expected.

Actually last time I used Vaadin 7.1.6. ant it has same problem.

Servlet 3.0, Java 7, Webspehere Application Server 8.5.

Happens in IE, Firefox and Chrome browsers in quite new versions.

I think this is about same thing:


I have rechecked that it does work with
Server: GlassFish
Browsers: Firefix 24.0 ( Mac and Linux ) , Safary 6.0.5 (8536.30.1)
Vaadin 7.1.7

Test1 : upload same 14KB file 20 times.
Test2 : upload same 9MB file 20 times.


I think the next step will have to be a small test app, that you confirmed is not working for you ( and upload to that Ticket ).
But my gut feel is it must be something with the server…

If I have 30 minutes free later today , I’ll make a small test app.

I have exactly the same problem as you. I tried everything I could on the Upload component.
The only solution I have for now is to catch this exception in my exception handler, but it’s ugly as you can imagine (I check its message to distinguish it from other IOExceptions…).
I don’t know what else to do unfortunately.

Is there a fix for this problem? I am having the same problem with displaying Images in the form of byte on the UI