HI,
I am having a problem using the Upload component. The file is uploaded but after that when Vaadin is processing the Multipart body an exception is thrown:
Caused by: java.lang.ArrayIndexOutOfBoundsException: 56
at com.vaadin.server.communication.FileUploadHandler$SimpleMultiPartInputStream.getBuffered(FileUploadHandler.java:170)
at com.vaadin.server.communication.FileUploadHandler$SimpleMultiPartInputStream.matchForBoundary(FileUploadHandler.java:150)
at com.vaadin.server.communication.FileUploadHandler$SimpleMultiPartInputStream.read(FileUploadHandler.java:100)
at java.io.InputStream.read(InputStream.java:179)
at java.io.InputStream.read(InputStream.java:101)
at com.vaadin.server.communication.FileUploadHandler.streamToReceiver(FileUploadHandler.java:558)
My upload hander looks like this:
public LogoUpload(final StaticFileService staticFileSvc, final SubscriberDTO sub,
final ISubscriberConfigDAO subscriberConfig) {
super();
this.staticFileService = staticFileSvc;
this.subscriberConfigDAO = subscriberConfig;
this.subscriber = sub;
Upload upload = new Upload("Logo", this);
upload.addFailedListener(this);
upload.setImmediate(false);
Panel panel = new Panel("Logo Upload:");
panel.setWidth("400px");
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
panel.setContent(layout);
layout.addComponent(upload);
layout.addComponent(image);
image.setVisible(false);
setCompositionRoot(panel);
}
@Override
public OutputStream receiveUpload(final String filename, final String mimeType) {
try {
File temp = File.createTempFile("upload", null);
logger.debug("temp file path: " + temp.getAbsolutePath());
FileOutputStream fos = new FileOutputStream(temp);
logger.info("*****upload stream created for file: " + filename);
return fos;
} catch (IOException ex) {
logger.error("Failed to create temp file for subscriber logo upload: " + ex.getMessage(), ex);
return null;
}
}
@Override
public void uploadFailed(final Upload.FailedEvent event) {
Exception ex = event.getReason();
logger.error("Failed to upload subscriber logo: " + ex.getMessage(), ex);
Notification.show("Logo uploaded failed. Please try again.", Notification.Type.ERROR_MESSAGE);
}
@Override
public void uploadSucceeded(final Upload.SucceededEvent event) {
logger.info("upload done...." + event.getFilename());
}
I have tried vaadin versions: 7.10.0, 7.2.0 and 7.2.1
The app server is running: GlassFish Server Open Source Edition 4.0 (build 89)
We are also using spring with this app and its version is: 3.2.9.RELEASE
I have tried the lastest version of chrome, firefox and ie results are the same in each browser.
Any help is greatly appreciated.
Thanks,
Andrew
Edit forgot to use code formatter.