• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does anyone know what these error means?

 
Ellen fish
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21189
80
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic