In the process of migrating to Tapestry 4 (final), the Upload component failed with a null pointer exception at line 84 in Upload.java. Top few lines of the exception stack trace are:

---------------------------
Stack Trace:
org.apache.tapestry.form.Upload.rewindFormComponent(Upload.java:84)
org.apache.tapestry.form.AbstractFormComponent.renderComponent(AbstractFormComponent.java:115)
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:434)
.....
-----------------------------

I looked through JIRA; I could not locate a report on this specific error. Anyway, I looked at the source and noticed that the error is caused by the "file" variable being null when no file is being uploaded.

------------------------------------
IUploadFile file = getDecoder().getFileUpload(getName());

if (HiveMind.isBlank(file.getFileName())) //exception if "file" is null
{
    file = null;
}
------------------------

I added a test to check for "file" being null

if (file! = null && HiveMind.isBlank(file.getFileName()))

and the exception went away.

Regards
Sohail Aslam
sohail.aslam AT google mail dot calm


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to