7.3.8 - Clicking Upload button of the Upload component just clears the file

I’m using the Upload component in a form, I’ve implemented uploadSucceeded and receiveUpload and the code below works correctly on my local machine, however when I deploy to a test server running the same operating system (Ubuntu) and Application Server(Tomcat 7) the upload no longer works. The behaviour we see is that once a file is selected and upload clicked the form reset’s i.e. removes the filename selected. There are no errors etc… in the log and I’m finding it very hard to debug the Upload component.

Have you got any tips on how to fault find, I’ve tested that the tomcat service has permission to create files in the appropriate directory.

From the code below we don’t even see the first log message in receiveUpload being called.

/**
* @param event
* @see com.vaadin.ui.Upload.SucceededListener#uploadSucceeded(com.vaadin.ui.Upload.SucceededEvent)
*/
@Override
public void uploadSucceeded(SucceededEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format(“File uploaded %s”, event.getFilename()));
}

    File file = Paths.get(event.getFilename()).toFile();
    for (IAddFileView.IAddFileViewListener listener : listeners) {
        listener.addProjectFile(filePrefix, file);
    }
}

/**
 * @param filename
 * @param mimeType
 * @return
 * @see com.vaadin.ui.Upload.Receiver#receiveUpload(java.lang.String, java.lang.String)
 */
@Override
public OutputStream receiveUpload(String filename, String mimeType) {
    FileOutputStream fos = null;

    if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("Recieving upload %s", filename));
    }

    try {
        // Open the file for writing.
        final Path uploadFile = fileSystem.getPath(uploadDir.toString(), filePrefix + "-" + filename);
        fos = new FileOutputStream(uploadFile.toFile());
    } catch (IOException e) {
        LOG.error(e);
       return null;
    }
    return fos; // Return the output stream to write to
}

and in the same class add the Upload component to the layout:

protected void buildLayout() {
setSpacing(false);
setMargin(false);

    upload = new Upload("File", this);
    upload.addSucceededListener(this);

    addComponent(upload);
}

Just to follow up on this, it seems like this is to-do with the size of the file being uploaded, I can’t see where the maximum allowed is being set so I assume the component takes it’s max file size allowed from the application server in this case Tomcat?

I’m still unsure why no exceptions or errors were thrown from the Upload which I might spend a little time investigating, just because it’s interesting and it’s been a little tricjy to figure out why there’s an issue.