File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes FilePermissionException on UNIX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "FilePermissionException on UNIX" Watch "FilePermissionException on UNIX" New topic
Author

FilePermissionException on UNIX

christy smile
Ranch Hand

Joined: Oct 15, 2001
Posts: 101
Hi, all,
I get a java.io.FilePermission exception while writing to or reading to db.db file. This exception only occurs when running on UNIX platform, it works fine on Windows. In addition, the permission of the file is both readable and writable. The following is the stack trace for the exception.
Please help me with this, I have been debugging this for a while, and still have no clue what has caused the problem. Thank you!!!
RMIServerDBAdapter exception: access denied (java.io.FilePermission db.db write)
java.security.AccessControlException: access denied (java.io.FilePermission db.d
b write)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:272)
at java.security.AccessController.checkPermission(AccessController.java:
399)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkWrite(SecurityManager.java:978)
at java.io.File.canWrite(File.java:527)
at jdev.db.Data.<init>(Unknown Source)
at jdev.server.RMIServerDBAdapter.<init>(Unknown Source)
at jdev.server.RMIServerDBAdapter.main(Unknown Source)
christy smile
Ranch Hand

Joined: Oct 15, 2001
Posts: 101
Hi, All,
By the way, the policy file grants permission for everything! And it is really the AccessControlException caused by the FilePermission.
Thanks!
Christy
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
Do you have
permission java.io.FilePermission
"/suncertify/db/db.db", "read,write";
in your java.policy file?
christy smile
Ranch Hand

Joined: Oct 15, 2001
Posts: 101
Hi, sai,
Thank you for the reply. I had all permission granted originally. But I added the line you recommended, it still did not work . Any other suggestions?
Thanks.
Christy
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
I suggest not using the RMI Security Manager and the java.policy file. You can also check to see whether db.db has write permission from the Unix point of view?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

You probably have this problem on the RMISecurityManager on the Server side.
Do as Sai says and just don't use RMISecurity or policy files.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
christy smile
Ranch Hand

Joined: Oct 15, 2001
Posts: 101
Hi, Sai, Mark,
I thought the problem might be related to the RMISecurityManager. You are confusing me now. I am using RMI to implement the remote connection, doesn't that mean I have to use RMISecurityManager and policy file?? Is there anyway around it? Thank you!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

doesn't that mean I have to use RMISecurityManager and policy file?? Is there anyway around it? Thank you!

No, actually you don't have to use it at all.
I actually only used it on the client side. I had tried on the server side, but I got errors, so I removed it. I figured it would be the client that would be rogue anyway, if there was problems.
But there are some who didn't have it at all and did not lose points because of it.
Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FilePermissionException on UNIX