• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception Occurred when I added policy file

 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys
I add a policy file to my project and start ServerGUI when I try to use a button to show a File Chooser it blows up and shows the list of exception below, and here is my policy file
grant {
permission java.security.AllPermission;
};
I can't figure out what's wrong?
Any idea or comment would be really appreciated
Thanks
Sam
here is the my command line and list of errors I got,(I am running WINXP)
C:\suncertify>java -Djava.security.manager -Djava.security.policy=${HOME}/suncer
tify/policyfile suncertify.FBNServer
Exception occurred during event dispatching:
java.security.AccessControlException: access denied (java.util.PropertyPermissio
n user.home read)
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.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at javax.swing.filechooser.FileSystemView.getHomeDirectory(Unknown Sourc
e)
at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at suncertify.server.ServerController.doBrowseAction(ServerController.ja
va:213)
at suncertify.server.ServerController.access$400(ServerController.java:2
2)
at suncertify.server.ServerController$6.actionPerformed(ServerController
.java:82)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow
n Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam,

C:\suncertify>java -Djava.security.manager -Djava.security.policy=${HOME}/suncer
tify/policyfile suncertify.FBNServer

The -Djava.security.manager causes the VM to apply to your application the same restrictions that poor Applets must endure. Believe me you don't want to run your server in a sandbox as you have seen the results. The setting of the policy file will now have no effect after setting this property. Besides that is not one of the allowable command line parameters according to the instructions.
If you want to install a security manager do it inside the server like this:

Hope this helps,
Michael Morris
 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael,
Your comments are always helpfull.
As far as I unndrestand, if I copied my stubs in local(client) application, then I don't need to have any security manager, is that right??
I used that command to run my policy file but I think this is a wrong syntax.
Regards
Sam
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam,
Yes. So long as no stubs have to be loaded dynamically there should be no need for a security manager. But, since it only takes one line of code, why not prepare for some future change in the application that may require loading stubs dynamially?
Hope this helps,
Michael Morris
 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
Whenever I try that security manager in my server application, it run my application like an applet and then I got that error that I mentioned above.I tried at home in XP and at work in Win2K and both have the same problem,
any comment?
Regards,
Sam
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is why I did not use a SecurityManager or a policy file... I just mentioned that I did not use dynamic loading, but it would be a nice future enhancement... but I did lose a few points and I guess that could be why
 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nate,
I am gonna use policy file but not security manager,
Thanks
Sam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic