File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes A BIG Problem using java policy files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "A BIG Problem using java policy files" Watch "A BIG Problem using java policy files" New topic

A BIG Problem using java policy files

Parth Mehta

Joined: Mar 02, 2007
Posts: 7
Hi Everyone, I have some trouble using policy files, which I hope someone might help me with. Here is all the information you need:-

1) I am trying to build a small program to test JMX security(probably not important, but mentioned anyway )

2) I have a policy file "server.policy" in the SAME directory as my Server.class file which has the "main" method".

3) I have this entry in the policy file:
grant codeBase "file:C:/xyz/*" {
permission "createMBeanServer";
The whole directory is C:\xyz\Server.class (Windows XP machine)

4) I have made entry into for the path of this file so that i dont have to explicitly point to it during running of my program everytime.
using policy.url.3=file:C:/xyz/server.policy"

5) When I run the java program with security manaber enabled, and that too in debug mode, My java program is NOT given the permission, even though it is shown that server.policy is actually used by the security manager successfully. One of the messages I get is this :-
policy: evaluate codesources:
Policy CodeSource: (file:/C:/xyz/* <no signer certificates>
The after many others, it throws me the following stack trace: access denied ( createMBeanServer)
at java.lang.SecurityManager.checkPermission(
at server.Server.main(

I really dont know what I am doing wrong.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
Does it work if you specify the permissions file explicitly?
Consider Paul's rocket mass heater.
subject: A BIG Problem using java policy files
jQuery in Action, 3rd edition