Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Uploader: fails to upload file on Windows
Uploader: fails to upload file on Windows [message #74661] Tue, 19 February 2008 08:51 Go to next message
David Donohue is currently offline David Donohue
Messages: 104
Registered: July 2009
Senior Member
Hello!
I am grateful for the Uploader module for RAP! Can anyone tell me how to
get the file uploaded? I am using Windows XP.

My UploadAdapter receives an UploadEvent object that is finished but
reports 0 files uploaded. Here is the UploadEvent I receive:
{finished=true uploadedParcial=0 uploadedTotal=0}

In fact I do not see the file in my temp directory. I change the temp
directory to be inside my standalone RAP application, but does not help.

Here is my UploadAdapter:
UploadAdapter uploadAdapter = new UploadAdapter() {
public void uploadFinished(final UploadEvent uploadEvent) {
if (uploadEvent.isFinished()) {
String uploadedFileName = upload.getLastFileUploaded();
File uploadedFile = new File(uploadedFileName);
//try to access the file: get "FileNotFoundException ... (The
system cannot find the file specified)"
}
}
};

Many thanks!
Re: Uploader: fails to upload file on Windows [message #74747 is a reply to message #74661] Tue, 19 February 2008 11:13 Go to previous messageGo to next message
Eclipse User
Originally posted by: nindl_go.hotmail.com

Hi David,

I encounter the same problem somtimes. Windows is somehow switching the temp
dir (Eclipse to User dir)

Have you tried

String uploadedFileName = upload.getLastFileUploaded();
File tempDir = new File ( System.getProperty("java.io.tempdir"));
File file = new File (tempDir, uploadedFileName);

Otherwise you should set the temp dir statically, must be something like
(when you start RAP with inside Eclipse)

File tempDir = new File ( "C:\Users\David\Eclipse 6.0");

Hope that helps...


"David Donohue" <dd@daviddonohue.com> schrieb im Newsbeitrag
news:34723804aa3471001a869c2f9e5b1f26$1@www.eclipse.org...
> Hello!
> I am grateful for the Uploader module for RAP! Can anyone tell me how to
> get the file uploaded? I am using Windows XP.
> My UploadAdapter receives an UploadEvent object that is finished but
> reports 0 files uploaded. Here is the UploadEvent I receive:
> {finished=true uploadedParcial=0 uploadedTotal=0}
>
> In fact I do not see the file in my temp directory. I change the temp
> directory to be inside my standalone RAP application, but does not help.
>
> Here is my UploadAdapter:
> UploadAdapter uploadAdapter = new UploadAdapter() {
> public void uploadFinished(final UploadEvent uploadEvent) {
> if (uploadEvent.isFinished()) {
> String uploadedFileName = upload.getLastFileUploaded();
> File uploadedFile = new File(uploadedFileName);
> //try to access the file: get "FileNotFoundException ... (The
> system cannot find the file specified)"
> }
> }
> };
>
> Many thanks!
>
>
Re: Uploader: fails to upload file on Windows [message #74968 is a reply to message #74747] Wed, 20 February 2008 08:59 Go to previous messageGo to next message
David Donohue is currently offline David Donohue
Messages: 104
Registered: July 2009
Senior Member
Gottfried,
I tried what you suggested but I believe the file is not being uploaded.
UploadEvent suggests nothing was uploaded
{finished=true uploadedParcial=0 uploadedTotal=0}
I added some tracers to
org.eclipse.rwt.widgets.upload.servlet.FileUploadServlet
and I find that FileUploadServlet.doGet() and doPost() are not being
called.

I also searched my entire hard drive and do not find the file in any temp
directories.
Below is my code. Thanks for any sage advice!
David


Upload upload = new Upload(composite, SWT.NONE, null, true);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
GridData.GRAB_HORIZONTAL);
upload.setLayoutData(gridData);
upload.addUploadListener(new UploadAdapter() {
public void uploadFinished(final UploadEvent uploadEvent) {
if (uploadEvent.isFinished() && uploadEvent.getUploadedTotal() >
0) {
String uploadedFileName = upload.getLastFileUploaded();
File tempDir = new File (System.getProperty("java.io.tmpdir"));
File uploadedFile = new File (tempDir, uploadedFileName);
//import the fileimportFile(uploadedFile.getName());
}
}
});
Re: Uploader: fails to upload file on Windows [message #75065 is a reply to message #74968] Thu, 21 February 2008 07:10 Go to previous messageGo to next message
Eclipse User
Originally posted by: nindl_go.hotmail.com

Hi David,

it's actually hard to figure out your problem without any exceptions.

Do you have write access to the temp directory?

Is the method renderInitialization() in the UploadLCA class correctly
initiating the
Qooxdoo widget, i. e. is the value of the method call u.getServlet()
"/upload"? Maybe
there is somehow a mess up with the names. Try to set the servlet name
manually, i. e.
new Upload(composite, SWT.NONE, "/myServlet", true). I encounter your
problem
when I replace the the u.getServlet() method call with a another false
value.

Trace the method readData() in the UploadLCA class. Do you receive any
values from
the JavaScript widget there?

Hope that helps

"David Donohue" <dd@daviddonohue.com> schrieb im Newsbeitrag
news:199f8b67c8109c7129676a3b293edf6c$1@www.eclipse.org...
> Gottfried,
> I tried what you suggested but I believe the file is not being uploaded.
> UploadEvent suggests nothing was uploaded
> {finished=true uploadedParcial=0 uploadedTotal=0}
> I added some tracers to
> org.eclipse.rwt.widgets.upload.servlet.FileUploadServlet
> and I find that FileUploadServlet.doGet() and doPost() are not being
> called.
>
> I also searched my entire hard drive and do not find the file in any temp
> directories.
> Below is my code. Thanks for any sage advice!
> David
>
>
> Upload upload = new Upload(composite, SWT.NONE, null, true);
> gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
> GridData.GRAB_HORIZONTAL);
> upload.setLayoutData(gridData);
> upload.addUploadListener(new UploadAdapter() {
> public void uploadFinished(final UploadEvent uploadEvent) {
> if (uploadEvent.isFinished() && uploadEvent.getUploadedTotal() >
> 0) {
> String uploadedFileName = upload.getLastFileUploaded();
> File tempDir = new File (System.getProperty("java.io.tmpdir"));
> File uploadedFile = new File (tempDir, uploadedFileName);
> //import the fileimportFile(uploadedFile.getName());
> }
> }
> });
>
Re: Uploader: fails to upload file on Windows [message #75097 is a reply to message #75065] Thu, 21 February 2008 15:22 Go to previous messageGo to next message
David Donohue is currently offline David Donohue
Messages: 104
Registered: July 2009
Senior Member
Gottfried,
Many thanks again for your help. I tried using your UploadDialog.java
class in my app and I get the same behavior of files not uploading.

> Do you have write access to the temp directory?
Yes I confirmed I do have access to the temp directory
File tempDir = new File(System.getProperty("java.io.tmpdir"));
//this returns true:
tempDir.canWrite();


> Is the method renderInitialization() in the UploadLCA class correctly
initiating the
> Qooxdoo widget, i. e. is the value of the method call u.getServlet()
"/upload"?

Upload.getServlet() returns "/upload"
I will reiterate that tracers in both doGet() and doPost() methods of
FileUploadServlet are not being called.

> Trace the method readData() in the UploadLCA class. Do you receive any
values from
> the JavaScript widget there?

Yes, I receive these values immediately upon clicking the "Upload" button:
finished - true
uploadParcial - 0
uploadTotal - 0

It seems that no upload servlet is called and nothing uploads, but
"finished" immediately returns true.
Could this be a bug?

Best,
David
Re: Uploader: fails to upload file on Windows [message #75147 is a reply to message #74968] Fri, 22 February 2008 01:21 Go to previous messageGo to next message
Eclipse User
Originally posted by: cheney_chen.i-len.com

David Donohue wrote:

> Gottfried,
> I tried what you suggested but I believe the file is not being uploaded.
> UploadEvent suggests nothing was uploaded
> {finished=true uploadedParcial=0 uploadedTotal=0}
> I added some tracers to
> org.eclipse.rwt.widgets.upload.servlet.FileUploadServlet
> and I find that FileUploadServlet.doGet() and doPost() are not being
> called.

so I think your problem is here:the servlet's url is wrong.one
question:where you run your application,in eclipse or standard?

In my application,I use the upload widget like this:
String application = RWT.getRequest().getContextPath();
application = application.trim();
final Upload upload1 = new Upload(firstCp, 0, application + "/upload",true);
and this work well also run in eclipse and standard.
Hope that helps.

Best regards.

cheney





> I also searched my entire hard drive and do not find the file in any temp
> directories.
> Below is my code. Thanks for any sage advice!
> David
>
>
> Upload upload = new Upload(composite, SWT.NONE, null, true);
> gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
> GridData.GRAB_HORIZONTAL);
> upload.setLayoutData(gridData);
> upload.addUploadListener(new UploadAdapter() {
> public void uploadFinished(final UploadEvent uploadEvent) {
> if (uploadEvent.isFinished() && uploadEvent.getUploadedTotal() >
> 0) {
> String uploadedFileName = upload.getLastFileUploaded();
> File tempDir = new File (System.getProperty("java.io.tmpdir"));
> File uploadedFile = new File (tempDir, uploadedFileName);
> //import the fileimportFile(uploadedFile.getName());
> }
> }
> });
Re: Uploader: fails to upload file on Windows [message #75215 is a reply to message #75147] Fri, 22 February 2008 08:37 Go to previous messageGo to next message
David Donohue is currently offline David Donohue
Messages: 104
Registered: July 2009
Senior Member
I think Cheney is onto something.

> where you run your application,in eclipse or standard?
As I am new to RAP, I don't quite know how to answer this. I used the RAP
Mail demo as a starting point. I am deploying my application as a
standalone, Jetty-powered app, by exporting as an Eclipse Feature as
described here
http://rapblog.innoopract.com/2007/11/rap-deployment-part-1- deploying-your.html


My app is running great, and I have added functionality.
I access it at this URL
http://127.0.0.1:7070/rap?startup=mail

However this is my first use of an alternative servlet within RAP. I see
that the bundle org.eclipse.rwt.widgets.upload declares the
FileUploadServlet to be accessible at "/upload"

&lt;extension point="org.eclipse.equinox.http.registry.servlets"&gt;
&lt;servlet alias="/upload"

class="org.eclipse.rwt.widgets.upload.servlet.FileUploadServlet "
load-on-startup="false"&gt;
&lt;/servlet&gt;
&lt;/extension&gt;

so I was passing "/upload" or null in the Upload constructor.

I tried your method but this
RWT.getRequest().getContextPath().trim()
is returning a blank: ""

Where is the servlet accessible? I get a 404 error when I open browser to
http://127.0.0.1:7070/upload

When I open a browser here
http://127.0.0.1:7070/rap/upload
I get this message
"HTTP ERROR: 500
An entry point named 'default' does not exist.
RequestURI=/rap/rap
Powered by Jetty://"

Thanks for your help!
David
Re: Uploader: fails to upload file on Windows [message #77460 is a reply to message #75065] Sun, 09 March 2008 05:34 Go to previous messageGo to next message
Eclipse User
Originally posted by: fappel.innoopract.com

Hi,

I run into the same problem using the upload widget. Debugging the
problem I detected that System.getProperty("java.io.tmpdir") returns a
different value in my demo app than it does in the FileUploadServlet.
I'm not sure at the moment how this can happen, but anyway I think that
servlets should use the servlets temp directory available using:

ServletContext context = session.getServletContext();
File tempDir = ( File )context.getAttribute(
"javax.servlet.context.tempdir" );

Another problem seems to me that each session uses the same temp dir,
which can cause problems, if different sessions try to upload a file
with the same name. Digging into this I noticed additionally that the
upload also creates a new session, which I think is undesirable.

To solve these problems I've made some changes in the Upload plugin and
RAP. I've registered the upload servlet to the RAP Servlet Context (see
plugin.xml). This ensures that the upload takes place in the same
session in which the according workbench exists. I provided a new method
Upload#getLastUploadedFile() that returns an java.io.File handle
pointing to the uploaded file. Each session uses an own temp directory
for uploading, so uploading files with the same name in different
sessions should not conflict. Usage:

final Upload upload = new Upload( parent, SWT.NONE, null, true );
UploadAdapter uploadAdapter = new UploadAdapter() {
public void uploadFinished( final UploadEvent uploadEvent ) {
if( uploadEvent.isFinished() ) {
File lastUploadedFile = upload.getLastUploadedFile();
[...]
}
}
}
};
upload.addUploadListener( uploadAdapter );


Ciao
Frank

-----Urspr√ľngliche Nachricht-----
Von: Gottfried Nindl [mailto:nindl_go@hotmail.com]
Bereitgestellt: Donnerstag, 21. Februar 2008 13:10
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Uploader: fails to upload file on Windows
Betreff: Re: Uploader: fails to upload file on Windows


Hi David,

it's actually hard to figure out your problem without any exceptions.

Do you have write access to the temp directory?

Is the method renderInitialization() in the UploadLCA class correctly
initiating the Qooxdoo widget, i. e. is the value of the method call
u.getServlet() "/upload"? Maybe there is somehow a mess up with the
names. Try to set the servlet name manually, i. e.
new Upload(composite, SWT.NONE, "/myServlet", true). I encounter your
problem when I replace the the u.getServlet() method call with a another
false value.

Trace the method readData() in the UploadLCA class. Do you receive any
values from the JavaScript widget there?

Hope that helps

"David Donohue" <dd@daviddonohue.com> schrieb im Newsbeitrag
news:199f8b67c8109c7129676a3b293edf6c$1@www.eclipse.org...
> Gottfried,
> I tried what you suggested but I believe the file is not being
uploaded.
> UploadEvent suggests nothing was uploaded {finished=true
> uploadedParcial=0 uploadedTotal=0} I added some tracers to
> org.eclipse.rwt.widgets.upload.servlet.FileUploadServlet
> and I find that FileUploadServlet.doGet() and doPost() are not being
> called.
>
> I also searched my entire hard drive and do not find the file in any
> temp directories.
> Below is my code. Thanks for any sage advice!
> David
>
>
> Upload upload = new Upload(composite, SWT.NONE, null, true); gridData
> = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
> GridData.GRAB_HORIZONTAL); upload.setLayoutData(gridData);
> upload.addUploadListener(new UploadAdapter() { public void
> uploadFinished(final UploadEvent uploadEvent) {
> if (uploadEvent.isFinished() && uploadEvent.getUploadedTotal()

> >
> 0) {
> String uploadedFileName = upload.getLastFileUploaded();
> File tempDir = new File
(System.getProperty("java.io.tmpdir"));
> File uploadedFile = new File (tempDir, uploadedFileName);
> //import the fileimportFile(uploadedFile.getName());
> }
> }
> });
>
Re: Uploader: fails to upload file on Windows [message #77475 is a reply to message #75065] Sun, 09 March 2008 05:42 Go to previous messageGo to next message
Eclipse User
Originally posted by: fappel.innoopract.com

Hi,

I run into the same problem using the upload widget. Debugging the
problem I detected that System.getProperty("java.io.tmpdir") returns a
different value in my demo app than it does in the FileUploadServlet.
I'm not sure at the moment how this can happen, but anyway I think that
servlets should use the servlets temp directory available using:

ServletContext context = session.getServletContext();
File tempDir = ( File )context.getAttribute(
"javax.servlet.context.tempdir" );

Another problem seems to me that each session uses the same temp dir,
which can cause problems, if different sessions try to upload a file
with the same name. Digging into this I noticed additionally that the
upload also creates a new session, which I think is undesirable.

To solve these problems I've made some changes in the Upload plugin and
RAP. I've registered the upload servlet to the RAP Servlet Context (see
plugin.xml). This ensures that the upload takes place in the same
session in which the according workbench exists. I provided a new method
Upload#getLastUploadedFile() that returns an java.io.File handle
pointing to the uploaded file. Each session uses an own temp directory
for uploading, so uploading files with the same name in different
sessions should not conflict. Usage:

final Upload upload = new Upload( parent, SWT.NONE, null, true );
UploadAdapter uploadAdapter = new UploadAdapter() {
public void uploadFinished( final UploadEvent uploadEvent ) {
if( uploadEvent.isFinished() ) {
File lastUploadedFile = upload.getLastUploadedFile();
[...]
}
}
};
upload.addUploadListener( uploadAdapter );

Note that I've set the showProgress parameter of the Upload constructor
to true. It didn't work with the parameter set to false. I will have a
look at this at a later point in time.

Giving the whole thing a second thought I'm not sure whether it is a
good idea to save the file in the temp directory with the 'original'
name, maybe we should use a more 'cryptical' name to avoid any conflicts
at all.

Changes are in CVS, note that you also have to update the RAP bundles to
get everything to work.


Ciao
Frank

-----Urspr√ľngliche Nachricht-----
Von: Gottfried Nindl [mailto:nindl_go@hotmail.com]
Bereitgestellt: Donnerstag, 21. Februar 2008 13:10
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Uploader: fails to upload file on Windows
Betreff: Re: Uploader: fails to upload file on Windows


Hi David,

it's actually hard to figure out your problem without any exceptions.

Do you have write access to the temp directory?

Is the method renderInitialization() in the UploadLCA class correctly
initiating the Qooxdoo widget, i. e. is the value of the method call
u.getServlet() "/upload"? Maybe there is somehow a mess up with the
names. Try to set the servlet name manually, i. e.
new Upload(composite, SWT.NONE, "/myServlet", true). I encounter your
problem when I replace the the u.getServlet() method call with a another
false value.

Trace the method readData() in the UploadLCA class. Do you receive any
values from the JavaScript widget there?

Hope that helps

"David Donohue" <dd@daviddonohue.com> schrieb im Newsbeitrag
news:199f8b67c8109c7129676a3b293edf6c$1@www.eclipse.org...
> Gottfried,
> I tried what you suggested but I believe the file is not being
uploaded.
> UploadEvent suggests nothing was uploaded {finished=true
> uploadedParcial=0 uploadedTotal=0} I added some tracers to
> org.eclipse.rwt.widgets.upload.servlet.FileUploadServlet
> and I find that FileUploadServlet.doGet() and doPost() are not being
> called.
>
> I also searched my entire hard drive and do not find the file in any
> temp directories.
> Below is my code. Thanks for any sage advice!
> David
>
>
> Upload upload = new Upload(composite, SWT.NONE, null, true); gridData
> = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
> GridData.GRAB_HORIZONTAL); upload.setLayoutData(gridData);
> upload.addUploadListener(new UploadAdapter() { public void
> uploadFinished(final UploadEvent uploadEvent) {
> if (uploadEvent.isFinished() && uploadEvent.getUploadedTotal()

> >
> 0) {
> String uploadedFileName = upload.getLastFileUploaded();
> File tempDir = new File
(System.getProperty("java.io.tmpdir"));
> File uploadedFile = new File (tempDir, uploadedFileName);
> //import the fileimportFile(uploadedFile.getName());
> }
> }
> });
>
Re: Uploader: fails to upload file on Windows [message #78308 is a reply to message #75215] Fri, 14 March 2008 07:55 Go to previous message
Eclipse User
Originally posted by: nindl_go.hotmail.com

Hi David,

I posted a message in the "Changes to Upload widgets (sandbox)" thread.
I think your problem can be solved there too.

Best regards,

Gottfried

"David Donohue" <dd@daviddonohue.com> schrieb im Newsbeitrag
news:0eb93c7534f26e204909febaa2fe16bf$1@www.eclipse.org...
>I think Cheney is onto something.
>> where you run your application,in eclipse or standard?
> As I am new to RAP, I don't quite know how to answer this. I used the RAP
> Mail demo as a starting point. I am deploying my application as a
> standalone, Jetty-powered app, by exporting as an Eclipse Feature as
> described here
> http://rapblog.innoopract.com/2007/11/rap-deployment-part-1- deploying-your.html
>
> My app is running great, and I have added functionality.
> I access it at this URL
> http://127.0.0.1:7070/rap?startup=mail
>
> However this is my first use of an alternative servlet within RAP. I see
> that the bundle org.eclipse.rwt.widgets.upload declares the
> FileUploadServlet to be accessible at "/upload"
>
> &lt;extension point="org.eclipse.equinox.http.registry.servlets"&gt;
> &lt;servlet alias="/upload"
>
> class="org.eclipse.rwt.widgets.upload.servlet.FileUploadServlet "
> load-on-startup="false"&gt;
> &lt;/servlet&gt;
> &lt;/extension&gt;
>
> so I was passing "/upload" or null in the Upload constructor.
> I tried your method but this
> RWT.getRequest().getContextPath().trim()
> is returning a blank: ""
>
> Where is the servlet accessible? I get a 404 error when I open browser to
> http://127.0.0.1:7070/upload
>
> When I open a browser here http://127.0.0.1:7070/rap/upload
> I get this message
> "HTTP ERROR: 500
> An entry point named 'default' does not exist.
> RequestURI=/rap/rap
> Powered by Jetty://"
>
> Thanks for your help!
> David
>
Previous Topic:Tree display problem
Next Topic:Table - dynamic scroll bars
Goto Forum:
  


Current Time: Tue Jul 29 23:16:32 EDT 2014

Powered by FUDForum. Page generated in 0.02795 seconds