Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Upload from Servlet Using JCIFS

 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am tying to get the following servlet to work with JCIFS but I get an error:

SystemOut O java.io.FileNotFoundException: smb:\webergv;xxx:xxx@gvsvr03\drawings\wgen\pre_pdf\sourcefiles\862000\862144B1.rtf (The filename, directory name, or volume label syntax is incorrect)


 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you independently verify that there is a file at?

gvsvr03\drawings\wgen\pre_pdf\sourcefiles\862000\862144B1.rtf

Can you independently verify that you have permission to?

smb:\webergv;xxx:xxx@gvsvr03
 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martijn Verburg wrote:Can you independently verify that there is a file at?

gvsvr03\drawings\wgen\pre_pdf\sourcefiles\862000\862144B1.rtf

Can you independently verify that you have permission to?

smb:\webergv;xxx:xxx@gvsvr03


Yes to the above. However, I have changed my code and got it to work from my workbench using local server host but when I move it to the production server(iSeries - AS400 server) it says in file does not exist. How can I get the servlet to see a file on the client so it can be uploaded?


 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
smb:\webergv;xxx:xxx@gvsvr03 is the bit I'd be investigating (I've never seen that protocol used directly from java, it's Samba right?). Can you write a small stand alone class/method to test that you can connect via this method? Try connecting to a different server and/or using different credentials and/or looking for a different file (perhaps one at the root level of the server file system).
 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martijn Verburg wrote:smb:\webergv;xxx:xxx@gvsvr03 is the bit I'd be investigating (I've never seen that protocol used directly from java, it's Samba right?). Can you write a small stand alone class/method to test that you can connect via this method? Try connecting to a different server and/or using different credentials and/or looking for a different file (perhaps one at the root level of the server file system).


I don't understand because the JCIFS library was suggested by another JavaRanch person. I am currently using it to read directory contents. And it works just fine locally.

My code is breaking on the FileInputStream line.

SystemOut O No such path or directory. C:\SDETest.rtf
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought you said above that you had it working locally?

However, I have changed my code and got it to work from my workbench using local server host but when I move it to the production server(iSeries - AS400 server) it says in file does not exist.


 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martijn Verburg wrote:I thought you said above that you had it working locally?



Steve Dyke wrote:

That is correct:

I don't understand because the JCIFS library was suggested by another JavaRanch person. I am currently using it to read directory contents. And it works just fine locally.

My code is breaking on the FileInputStream line.

SystemOut O No such path or directory. C:\SDETest.rtf


The FileInputStream does not fail when I run on local Application Server just on production server. It is behaving like when ran from production application server that it is trying to find the file on that local server instead on the client machine.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, OK I think I was looking at the wrong problem. So the real problem is that



Is returning you a list of Items who's names are like "C:\SDETest.rtf", so when you execute:



It can't find it on the server because "C:\SDETest.rtf" doesn't exist.

So question is, where _is_ SDETest.rtf on the server? And why isn't the item.getName() returning the real location?
 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martijn Verburg wrote:

So question is, where _is_ SDETest.rtf on the server? And why isn't the item.getName() returning the real location?


What other property or method of FileItem can I use to get the real location?
 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martijn Verburg wrote:
It can't find it on the server because "C:\SDETest.rtf" doesn't exist.

So question is, where _is_ SDETest.rtf on the server? And why isn't the item.getName() returning the real location?


I have changed the FileInputStream to:



This seems to work but is this the correct way?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would argue that is a better way yes, as you're wanting to deal with data streams as opposed to a physical file.
 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martijn Verburg wrote:I would argue that is a better way yes, as you're wanting to deal with data streams as opposed to a physical file.


Thanks for all your help. I have just started developing in Java and have a long way to go.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No worries! Glad you were able to solve the problem (always the best way to learn!)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic