• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet cannot access local C: Drive File

 
Eric Racin
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Servlet .class that has worked for years is being migrated to Win Server 2012. As part of the upgrade, we are using Tomcat 7 and JDK 8. I access a local C: drive file with the line
I get the error msg
Error: java.io.FileNotFoundException (the system cannot find the file specified)
.
Any ideas why it can't locate the local server hard drive? Everything else in the Servlet works well.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File permissions perhaps?

What does your app do this? It's a bit of a code smell.
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget that under Windows you have to run the Tomcat service under a user ID which has access to that folder. The usual system IDs used for services won't work.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could it be an issue with the FileSeparator character?

Remember, Windows uses "\" (backward slash) character whereas Unix/Mac uses "/" (forward slash).

As "\" is an escape character, you need to specify the same as follows.



Note: It is always better to use for such platform specific attributes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!