Upload Exception wwhile using Upload Component

Hello every one , while using upload component the following exception with error message was thrown , can any one please explain or provide solution for me , i am in a urgent need for this . Thanx in advance .

SEVERE: Terminal error:
com.vaadin.terminal.gwt.server.UploadException: Upload failed
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.streamToReceiver(AbstractCommunicationManager.java:616)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleSimpleMultipartFileUpload(AbstractCommunicationManager.java:469)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleFileUpload(CommunicationManager.java:257)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:495)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
	at com.vaadin.ui.Upload$1.getOutputStream(Upload.java:1007)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.streamToReceiver(AbstractCommunicationManager.java:555)
	... 20 more

Hi!

What version of Vaadin are you using, and how do you create the Upload component (specifically, do you attach a Receiver to it?).

Hi , im using vaadin 6.6.6
the code snippet is

You seem to have the Receiver method implemented, but you don’t assign a Receiver to the Upload component. See the Upload.setReceiver(Upload.Receiver) method.


same problem to me also .


com.vaadin.server.UploadException: Upload failed
at com.vaadin.server.communication.FileUploadHandler.streamToReceiver(FileUploadHandler.java:627)
at com.vaadin.server.communication.FileUploadHandler.handleFileUploadValidationAndData(FileUploadHandler.java:456)
at com.vaadin.server.communication.FileUploadHandler.doHandleSimpleMultipartFileUpload(FileUploadHandler.java:403)
at com.vaadin.server.communication.FileUploadHandler.handleRequest(FileUploadHandler.java:285)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1409)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: com.vaadin.server.NoOutputStreamException
at com.vaadin.server.communication.FileUploadHandler.streamToReceiver(FileUploadHandler.java:555)
… 27 more


I added upload.setReceiver(uploader). but still same upload exception there. how i solve it?
[color=#40E0D0]

[/color] @thomas Mattsson

What does your receiver look like? It needs to return an OutputStream when receiveUpload is called


Hi Tom

,

Thanks for responding.

This is my snippet :
[color=#800080]
Upload upload = new Upload(“”, null);

             // Put the upload component in a panel
       Embedded     image = new Embedded();
            image.setVisible(false);
            image.setWidth("75px");
            image.setHeight("95px");
            img_panel.setHeight("75px");
            img_panel.setWidth("95px");
            img_panel.setVisible(false);
            
            final ImageUploader uploader = new ImageUploader(); 

                upload.setReceiver(uploader);
                upload.addSucceededListener(uploader);

[/color]

            [color=#008000]

class ImageUploader implements Receiver, SucceededListener
{
[/color]

          [color=#8B4513]

public OutputStream receiveUpload(String filename, String mimeType) {
// Create upload stream
FileOutputStream fos = null; // Output stream to write to
if(filename.equals(“”))
{
Notification.show(“Please Choose the Image”);
}
else
{
String file_name=StringUtils.split(filename,“.”);
ArrayList img_extension = new ArrayList();
img_extension.add(“jpg”);
img_extension.add(“jpeg”);
img_extension.add(“png”);
img_extension.add(“tif”);
img_extension.add(“bmp”);
img_extension.add(“gif”);
img_extension.add(“ico”);
if(file_name.length<2 || (file_name.length>1 && !img_extension.contains(file_name[1]
)))
{
Notification.show(“Please Choose Valid Image”);
}
}

               try {
                       file = new File(System.getProperty("java.io.tmpdir")+filename);
  
                fos = new FileOutputStream(file);
                  }
                  } catch (Exception e) {
                   e.printStackTrace();
                   System.out.println(e);
                   return null;
               }
               return fos; // Return the output stream to write 
           }

[/color]

//upload success event
[color=#4B0082]
public void uploadSucceeded(SucceededEvent event) {
// Show the uploaded file in the image viewer
if(image_old!=null)
image_old.setVisible(false);
img_panel.setVisible(true);
image.setVisible(true);
image.setSource(new FileResource(file));
img_panel.setContent(image);

               try {
                img_file=new FileInputStream(file);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                Notification.show(
                           "Could not open file<br/>", e.getMessage(),
                           Notification.TYPE_ERROR_MESSAGE);
                   e.printStackTrace();
            }
           }

[/color]

};

I don’t see anything wrong. Have you tried debugging the ImageUploader? Does it get called, and does it return an OutputStream?

yeah… i tried that too… is nothing wrong in to that… anyway i fixed that issue in another way by invoking another Exception and i catched that.

Thanks again for responding Tom.

veerakumarasamy V , I am getting same exception, in what way did you fix that issue ? Can you please tell its urgent to me .