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 Access denied(java.io.FilePermission db.db write) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Access denied(java.io.FilePermission db.db write)" Watch "Access denied(java.io.FilePermission db.db write)" New topic
Author

Access denied(java.io.FilePermission db.db write)

Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
trying to start my server
Access denied(java.io.FilePermission db.db write)
java -Djava.security.policy=myPermit.policy suncertify.server.flyServer db.db
help Lisa
Glenn Opdycke-Hansen
Ranch Hand

Joined: Feb 16, 2001
Posts: 40
so, what was in the myPermit.policy file.
Also what directory was it in? What was the current directory?
Is there a way to determine the policy file from the java code?
------------------
--glenn
[This message has been edited by Glenn Opdycke-Hansen (edited May 18, 2001).]


--glenn
aleks nikolic
Greenhorn

Joined: Mar 04, 2001
Posts: 25
Lisa, what does your policy file say ?
Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
here is my policy any help greatly appreciated

grant
{
permission java.security.AllPermissions;
permission java.net.SocketPermission"*:1024-65535","connect,accept,resolve";
permission java.net.SocketPermission"*:1-1023","connect,resolve";
};
Thanks Lisa
ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
grant
{
permission java.security.AllPermissions;
permission java.net.SocketPermission"*:1024-65535","connect,accept,resolve";
permission java.net.SocketPermission"*:1-1023","connect,resolve";
"c://project//suncertify//db//db.db", "read,write";
};
ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
Please discard the last message. Sorry I missed one line Here is correct format. You need to edit the file directory according to your directory structure.
grant
{
permission java.security.AllPermissions;
permission java.net.SocketPermission"*:1024-65535","connect,accept,resolve";
permission java.net.SocketPermission"*:1-1023","connect,resolve";
permission java.io.FilePermission
"c://project//suncertify//db//db.db", "read,write";
};
Glenn Opdycke-Hansen
Ranch Hand

Joined: Feb 16, 2001
Posts: 40
Why not start with a simple policy file?
I thought it was important to document how to specify a policy file. I did not know that it was required to have a policy file that was appropriate for a production system.
The following file worked for me.
grant {
// Allow everything for now
permission java.security.AllPermission;
};
Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
Thanks very much got it working just have to fix the classCast Exception

Thanks Lisa
Thestud
Greenhorn

Joined: Jul 16, 2001
Posts: 1
Hello,
I have a similar problem. I have an applet reading a txt file and then plotting a graph. The text file and the applet class files are in the same directory. when i run on my local machine, it runs fine, and the graphs come up, but when i try to access from some other machine, then the console pops up an
java.security.AccessControlException: access denied (java.io.FilePermission \\C\vj\rxhast\Chart2D_1.3.0\net\sourceforge\chart2d\mydata.txt read)
any help would be appreciated.
Vj
Akanimo Udoh
Ranch Hand

Joined: Jun 11, 2001
Posts: 48

TheStud,

Your problem is pretty direct. On your local machine your text file is probably located in the same location as you applet (or has default policy file set to AllPermissions) so you won't have any problem.

When you try it from another machine its another case altogether. We all know how Java prides itself on being a secure platform such that malicious code cannot take advantage of the system running the Java app. As such the applet is not given the permissions to run amok and go thru the files on your machine or your network.

To resolve this you have to explicitly set permissions giving permission to the VM under which the applet is running OR alternatively you can sign the applet, in which case the browser should allow the applet to access the file.

But I think the best solution would be to use ONLY the file name ('mydata.txt') without the extension when trying to open/access the file. That way if the file is in the same directory as the applet the applet will be able to open/access the file without any need for the above security details. I think this would preferred.

Let me know it this helps.

Akanimo.

P.S. - Better change your username to your own name (or alias) before the bartenders/sheriff get on your case
 
Don't get me started about those stupid light bulbs.
 
subject: Access denied(java.io.FilePermission db.db write)