• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading remote file using URL through web application  RSS feed

 
Naresh Kavala
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am trying to read remote file data using URL class through webapplication(Running on jboss 4.2.3 server).
I can read the file data using standalone java program where as same peace of code giving problem when running the the code using server.
Here posting sample code



Could anybody please suggestion, whats wrong when I use it through server.

Warm Regards,
Naresh Kavala
 
Badal Chowdhary
Ranch Hand
Posts: 34
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Naresh,

1) Did you try to disable Firewall and then read the file?

2) What is the exception you are getting?


Thanks,
Badal
 
Paul Clapham
Sheriff
Posts: 22817
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I expect the difference is that JBoss is running as a Windows service, and it's running as the default service user ID. Try running JBoss as a real user ID, I know for sure that fixes a similar problem involving UNC paths.

And if that doesn't work then forget about file:// URLs and switch to using JCIFS.
 
Naresh Kavala
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Badal Chowdhary wrote:Hi Naresh,

1) Did you try to disable Firewall and then read the file?

2) What is the exception you are getting?


Thanks,
Badal


Hi Badal,

Thanks a lot reply.
I get FileNotFoundException...No I have not tried Firewall disable..But same syntax is working fine with standalone java program.
I will try with disabling firewall
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need not two but four slashes. The file:// protocol already has two, but you need another two to make the URL use CIFS / SMB. Right now, your URL is looking for a file server_ip/path of dir/filename.txt relative to the current directory.

Check out the following example:
Note the four backslashes in the file; that's two because that's what CIFS / SMB needs, and then those duplicated to escape them in the Java string. The printing will show you the actual value.

But I second Paul's suggestion on using JCIFS instead.
 
Naresh Kavala
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:You need not two but four slashes. The file:// protocol already has two, but you need another two to make the URL use CIFS / SMB. Right now, your URL is looking for a file server_ip/path of dir/filename.txt relative to the current directory.

Check out the following example:
Note the four backslashes in the file; that's two because that's what CIFS / SMB needs, and then those duplicated to escape them in the Java string. The printing will show you the actual value.

But I second Paul's suggestion on using JCIFS instead.


Hi Rob,
I have done this using JCIFS. Thanks a lot guys for your help

Regards,
Naresh
 
Naresh Kavala
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naresh Kavala wrote:
Badal Chowdhary wrote:Hi Naresh,

1) Did you try to disable Firewall and then read the file?

2) What is the exception you are getting?


Thanks,
Badal


Hi Badal,

Thanks a lot for your reply.
I get FileNotFoundException...No I have not tried Firewall disable..But same syntax is working fine with standalone java program.
I will try with disabling firewall
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!