Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.io.File.getCanonicalFile throwing SecurityException

 
Darryl Nortje
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there Guys,

I'm just being preemptive here, cos you know how things work in dev, and then you move it into test, and things that were always working on your machine stop working. ;-)

I was wondering, Why, or rather, under which conditions would a SecurityException be thrown when calling getCanonicalFile, or getCanonicalPath from the File class. Currently I am doing this in dev, and it's working no probs. I am just wondering why this would happen, and if it does happen, what I can do to stop this from happening.

The java doc says... "If a required system property value cannot be accessed, or if a security manager exists and its java.lang.SecurityManager#checkRead method denies read access to the file"

What can I do to gain read access if this SecurityManager dude tells me I don't have read access? Will that be an operating system setting?

Thanks in advance.


cheers
Darryl
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to find out if the web app is run with a security manager, and if so, what kind of security manager it is. The server admins should be able to tell you about that.

A security manager will generally be present if this is a shared hosting environment. In that case you'll likely get an exception if the File object in question points to a directory that is not under the control of your account.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic