• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

java.io.File.getCanonicalFile throwing SecurityException

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What's wrong? Where are you going? Stop! Read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic