aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Exception Occurred when I added policy file 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 "Exception Occurred when I added policy file" Watch "Exception Occurred when I added policy file" New topic
Author

Exception Occurred when I added policy file

Sam Stackly
Ranch Hand

Joined: May 04, 2002
Posts: 109
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

Joined: Jan 30, 2002
Posts: 3451
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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Sam Stackly
Ranch Hand

Joined: May 04, 2002
Posts: 109
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

Joined: Jan 30, 2002
Posts: 3451
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

Joined: May 04, 2002
Posts: 109
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

Joined: May 13, 2002
Posts: 301
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


scwcd, scjd, scjp<br /><a href="http://natejohnson.us" target="_blank" rel="nofollow">http://natejohnson.us</a><br /><a href="http://rice.kuali.org" target="_blank" rel="nofollow">http://rice.kuali.org</a>
Sam Stackly
Ranch Hand

Joined: May 04, 2002
Posts: 109
Thanks Nate,
I am gonna use policy file but not security manager,
Thanks
Sam
 
wood burning stoves
 
subject: Exception Occurred when I added policy file