• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how do I get Rid of Error: D:/test/File.txt (No such file or directory) error

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,
I am in tough time and I need your help,

This is a web service
When I run it locally in Web service explorer it works fine but when I it run from an other pc it showing me the error D:/test/File.txt (No such file or directory)

I run it from local pc like this http://localhost:Port/FileUpload/UploadServiceService?wsdl it works fine

but when I run it from other pc like this http://hostIp:Port/FileUpload/UploadServiceService?wsdl it bring me prompts in web service explorer but on submit it shows error


here is the code


 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Khalid Habib wrote:D:/test/File.txt (No such file or directory)


What the error means, is quite obvious from the error message: it tells you that the file D:/test/File.txt does not exist. Do you have a drive D:, that contains a directory "test", that contains a file "File.txt"?

Did you actually want to write that file instead of read that file? You're using InputStream / FileInputStream in your code. That is for reading files. If you want to write a file, use OutputStream / FileOutputStream instead.
 
Rancher
Posts: 4614
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a web service.
The machine on which this is executing has no access whatsoever to the client machine, unless (as in your testing) the client is running on the same box.

So, for your file upload, sending the directory path is not going to work.
You need the client to send the actual file data.
 
Khalid Habib
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks lot dear friends,
Now I am using outputSteam instead of inputStream, File is being upload but when I open that file it contains no data, after uploading when I try to open it show me "The process cannot access the file because it being used by an other process"

here is new code
==========

 
Khalid Habib
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys
Actually my requirement is that ,I want create a web service that upload the file to ftp server which I have don but the main requirement is that it will be used from remote, means it will be used for uploading remotely from other systems, specified users will upload the files from their systems. so this program works fine at locally but when I try it remotely from other system it show me error that directory and file not found.
this web service will be uploaded on server. so user can access from server
guys please suggest me the way in which I do this .

Thanks in advance
 
Marshal
Posts: 25677
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no point in uploading a file unless you are uploading it to some particular location. You didn't tell us where you want to upload the files to -- it looks like you haven't thought that through yet?

Wait a minute, I just reread your post; you said you wanted to upload to an FTP server. But I don't see any code to upload to an FTP server in what you posted there, instead you're uploading to a file. So why aren't you uploading to an FTP server in that code?
 
Khalid Habib
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:There's no point in uploading a file unless you are uploading it to some particular location. You didn't tell us where you want to upload the files to -- it looks like you haven't thought that through yet?

Wait a minute, I just reread your post; you said you wanted to upload to an FTP server. But I don't see any code to upload to an FTP server in what you posted there, instead you're uploading to a file. So why aren't you uploading to an FTP server in that code?




Dear Paul Clapham,
ftpUrl = String.format(ftpUrl, user, pass, host, uploadPath);
System.out.println("Upload URL: " + ftpUrl);


URL url = new URL(ftpUrl);
URLConnection conn = url.openConnection();
OutputStream outputStream = conn.getOutputStream();
in this code connecting with ftp server.
 
Paul Clapham
Marshal
Posts: 25677
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that's not the way to transfer a file to an FTP server. But my question remains: why are you using a file on your server at all?
 
Khalid Habib
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Well, that's not the way to transfer a file to an FTP server. But my question remains: why are you using a file on your server at all?




Dear I have a Web application that accept attachment and that attachment goes to DB in form of clob and clob makes db Very heavy and app performance is becoming down day by day so I want resolve this issue, that's why seeking a alternate way in which I want store that attachment in a shared directory or any other place out of DB

Please suggest me. what is actual way to do this
 
Dave Tolls
Rancher
Posts: 4614
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you need to get your web service method to handle uploading a file.
At the moment it isn't.
It simply accepts a String representing the path on the client.

You need to use (and I'm a little rusty here) MTOM. At least that used to be the thing.

Here's a ranch thread from 2011. H Paul's posts are the one's I would look at, at least for MTOM.
 
Khalid Habib
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:So you need to get your web service method to handle uploading a file.
At the moment it isn't.
It simply accepts a String representing the path on the client.

You need to use (and I'm a little rusty here) MTOM. At least that used to be the thing.

Here's a ranch thread from 2011. H Paul's posts are the one's I would look at, at least for MTOM.



Thanks dear,
Let me try this then I will update
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic