wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Does anyone know what these error means? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Does anyone know what these error means?" Watch "Does anyone know what these error means?" New topic
Author

Does anyone know what these error means?

Ellen fish
Greenhorn

Joined: Oct 28, 2008
Posts: 27
Hello,
I'm running my rmi client and got the following errors.

java.io.FileNotFoundException: \logs\new.log (The system cannot find the path specified)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)



and

Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission createSecurityManager)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.<init>(Unknown Source)
at net.jini.security.Security$ClassContextAccess.<init>(Security.java:965)
at net.jini.security.Security$ClassContextAccess.<init>(Security.java:965)
at net.jini.security.Security$1.run(Security.java:167)
at java.security.AccessController.doPrivileged(Native Method)
at net.jini.security.Security.<clinit>(Security.java:165)
... 10 more

Does anyone have any suggestion on how to fix these two problems?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18765
    
  40

The first error is triggered when Java is trying to open a particular file for appending, and the file doesn't exist.

The other is a security error. It is likely that you are trying to do something that is not allowed.

Henry
[ November 03, 2008: Message edited by: Henry Wong ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Originally posted by Ellen fish:

Does anyone have any suggestion on how to fix these two problems?


For the fist one, add code to check if the file exists prior to trying to open it (see the isFile() method in the File class). If it does not exist, you need to create it first before trying to open it. (See the createNewFile() method in the File class.) You may also need to check the read and write permissions on the file. (See the File class for the canRead() and canWrite() methods.)


As for the second error, we'd need a bit more information on what it is you are trying to do that is generating the error. Also, is this a Java Applet or a Java Web Start application? Or a desktop application?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

Eh Mark? Ellen is trying to write, not read.

Writing to a file usually does not give problems. However, if one of the following (plus maybe some more) is true it does throw an exception:
  • The folder in which the file should be stored does not exist. isDirectory() can help you out, along with mkdirs().
  • That folder is actually a file.
  • The file system prevents you from creating or overwriting files in the folder (user permissions etc).
  • The file system prevents you from overwriting the file (e.g. readonly).
  • The same as the two above but then it's the Java Security Manager that prevents the access.

  • In your case the latter seems to apply. Do you happen to run this code in an applet?


    SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
    How To Ask Questions How To Answer Questions
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Does anyone know what these error means?