While uploading larger files (from around 100 - 150 Megabyte) via standard zk upload mechanism a NullPointerException is thrown in AuUploader line 103. This mostly happens when one uploads a file over the network. The try of reproduction on a local machine failed.
22.06.2011 17:25:06 org.zkoss.zk.au.http.AuUploader handleError:217
SCHWERWIEGEND: Failed to upload
>>java.lang.NullPointerException
>> at org.zkoss.zk.au.http.AuUploader.service(AuUploader.java:103)
>> at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:431)
>> at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:471)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>>...
Propably this defect goes into the same direction like this here: https://sourceforge.net/tracker/index.php?func=detail&aid=3313630&group_id=152762&atid=785191
I used the following zuml code and composer in a fresh eclipse project:
zuml:
<?page title="Auto Generated index.zul"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<zk>
<window id="picWin"
title="Hello World!! (ZK Version: ${desktop.webApp.version})"
border="normal" width="100%" apply="upload.UploadComposer">
<button id="upload" label="App-Load File"
upload="true,maxsize=${desktop.webApp.configuration.maxUploadSize}" />
<button id="clear" label="Clear" disabled="true"></button>
You see:
<label id="imgName"
value="@{picWin$composer.media.name,load-after='upload.onUpload,clear.onClick'}" />
<vbox id="pics" width="600px" height="300px">
</vbox>
</window>
</zk>
Composer:
package upload;
import org.zkoss.util.media.Media;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Image;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Vbox;
public class UploadComposer extends GenericForwardComposer {
private static final long serialVersionUID = -7909962998642083404L;
private Media media;
private final Image image = new Image();
private Vbox picWin$pics;
private Button picWin$clear;
private final static String PIC_ID = "thisPic";
public Media getMedia() {
return media;
}
public void setMedia(Media med) {
this.media = med;
}
public void onClick$clear() {
setMedia(null);
picWin$pics.removeChild(picWin$pics.getFellow(PIC_ID));
picWin$clear.setDisabled(true);
}
public void onUpload$upload(UploadEvent event) throws Throwable {
setMedia(event.getMedia());
if (event.getMedia() instanceof org.zkoss.image.Image) {
image.setContent((org.zkoss.image.Image) media);
image.setId(PIC_ID);
final Component first = picWin$pics.getFirstChild();
if (null != first) {
picWin$pics.removeChild(first);
}
image.setParent(picWin$pics);
picWin$clear.setDisabled(false);
System.out.println("received " + media.getName());
} else {
try {
Messagebox.show("Not an image: " + media, "Error", Messagebox.OK, Messagebox.ERROR);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Hi Graff,
What is the container that hosts your project? Is it Tomcat? Thanks.
Hi simonpai,
yes we're using the tomcat server in version 6.0.32 up to 7.0.16
I tried with minimum test code.
I tested to upload a 200mega file from firefox 4 in vmware.
Server host in tomcat 6.0.20
It's slow to native localhost, but it doesn't throw NPE.
NPE is throw each time if the file is more than 2GB.
Can you tell us more about how to reproduce the problem?
By through network? If two pc in same office, would it reproduce the problem?
How long does it take to upload such file?
Does it happen every time? Or by chance?
<zk>
<fileupload label="Upload">
<attribute name="onUpload">
org.zkoss.util.media.Media media = event.getMedia();
alert("complete");
</attribute>
</fileupload>
</zk>
Hey,
please apologise my late answer, I was on vacation.
We upload files via network in our office from one pc to another. Not via localhost.
We tried your minimal code in our office and the described exception was reproducably thrown. This happens near to the file selection. We would say this happens <10 seconds after the file to upload was chosen and the file-choose-dialog was closed.
Hi Gromok,
I tested following case but can not reproduce the problem,
could you provide more details?
test environment:
my NB upload to PC via wireless network
upload 222MB zip file
the only config in zk.xml
<system-config>
<max-upload-size>500000000</max-upload-size>
</system-config>
#################################################
zk 506 + tomcat 6: upload ok
apache-tomcat-6.0.32-windows-x64
JRE System Library = JDK 1.6.24
#################################################
zk 506 + tomcat 7: upload ok
apache-tomcat-7.0.19-windows-x64
JRE System Library = JDK 1.6.24
moved to
http://tracker.zkoss.org/browse/ZK-265